aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__algorithm/adjacent_find.h33
-rw-r--r--libcxx/include/__algorithm/all_of.h2
-rw-r--r--libcxx/include/__algorithm/any_of.h2
-rw-r--r--libcxx/include/__algorithm/binary_search.h7
-rw-r--r--libcxx/include/__algorithm/clamp.h4
-rw-r--r--libcxx/include/__algorithm/comp.h50
-rw-r--r--libcxx/include/__algorithm/comp_ref_type.h27
-rw-r--r--libcxx/include/__algorithm/copy.h158
-rw-r--r--libcxx/include/__algorithm/copy_backward.h142
-rw-r--r--libcxx/include/__algorithm/copy_if.h2
-rw-r--r--libcxx/include/__algorithm/copy_move_common.h163
-rw-r--r--libcxx/include/__algorithm/copy_n.h5
-rw-r--r--libcxx/include/__algorithm/count.h2
-rw-r--r--libcxx/include/__algorithm/count_if.h2
-rw-r--r--libcxx/include/__algorithm/equal.h29
-rw-r--r--libcxx/include/__algorithm/equal_range.h13
-rw-r--r--libcxx/include/__algorithm/fill.h8
-rw-r--r--libcxx/include/__algorithm/fill_n.h7
-rw-r--r--libcxx/include/__algorithm/find.h2
-rw-r--r--libcxx/include/__algorithm/find_end.h16
-rw-r--r--libcxx/include/__algorithm/find_first_of.h14
-rw-r--r--libcxx/include/__algorithm/find_if.h2
-rw-r--r--libcxx/include/__algorithm/find_if_not.h2
-rw-r--r--libcxx/include/__algorithm/for_each.h2
-rw-r--r--libcxx/include/__algorithm/for_each_n.h3
-rw-r--r--libcxx/include/__algorithm/generate.h2
-rw-r--r--libcxx/include/__algorithm/generate_n.h3
-rw-r--r--libcxx/include/__algorithm/half_positive.h2
-rw-r--r--libcxx/include/__algorithm/in_found_result.h4
-rw-r--r--libcxx/include/__algorithm/in_fun_result.h4
-rw-r--r--libcxx/include/__algorithm/in_in_out_result.h4
-rw-r--r--libcxx/include/__algorithm/in_in_result.h4
-rw-r--r--libcxx/include/__algorithm/in_out_out_result.h4
-rw-r--r--libcxx/include/__algorithm/in_out_result.h4
-rw-r--r--libcxx/include/__algorithm/includes.h16
-rw-r--r--libcxx/include/__algorithm/inplace_merge.h98
-rw-r--r--libcxx/include/__algorithm/is_heap.h7
-rw-r--r--libcxx/include/__algorithm/is_heap_until.h9
-rw-r--r--libcxx/include/__algorithm/is_partitioned.h2
-rw-r--r--libcxx/include/__algorithm/is_permutation.h260
-rw-r--r--libcxx/include/__algorithm/is_sorted.h7
-rw-r--r--libcxx/include/__algorithm/is_sorted_until.h9
-rw-r--r--libcxx/include/__algorithm/iter_swap.h4
-rw-r--r--libcxx/include/__algorithm/iterator_operations.h102
-rw-r--r--libcxx/include/__algorithm/lexicographical_compare.h9
-rw-r--r--libcxx/include/__algorithm/lower_bound.h6
-rw-r--r--libcxx/include/__algorithm/make_heap.h13
-rw-r--r--libcxx/include/__algorithm/make_projected.h100
-rw-r--r--libcxx/include/__algorithm/max.h11
-rw-r--r--libcxx/include/__algorithm/max_element.h9
-rw-r--r--libcxx/include/__algorithm/merge.h9
-rw-r--r--libcxx/include/__algorithm/min.h11
-rw-r--r--libcxx/include/__algorithm/min_element.h11
-rw-r--r--libcxx/include/__algorithm/min_max_result.h4
-rw-r--r--libcxx/include/__algorithm/minmax.h8
-rw-r--r--libcxx/include/__algorithm/minmax_element.h8
-rw-r--r--libcxx/include/__algorithm/mismatch.h16
-rw-r--r--libcxx/include/__algorithm/move.h177
-rw-r--r--libcxx/include/__algorithm/move_backward.h156
-rw-r--r--libcxx/include/__algorithm/next_permutation.h38
-rw-r--r--libcxx/include/__algorithm/none_of.h2
-rw-r--r--libcxx/include/__algorithm/nth_element.h13
-rw-r--r--libcxx/include/__algorithm/partial_sort.h21
-rw-r--r--libcxx/include/__algorithm/partial_sort_copy.h45
-rw-r--r--libcxx/include/__algorithm/partition.h10
-rw-r--r--libcxx/include/__algorithm/partition_copy.h2
-rw-r--r--libcxx/include/__algorithm/partition_point.h2
-rw-r--r--libcxx/include/__algorithm/pop_heap.h13
-rw-r--r--libcxx/include/__algorithm/prev_permutation.h39
-rw-r--r--libcxx/include/__algorithm/push_heap.h13
-rw-r--r--libcxx/include/__algorithm/ranges_adjacent_find.h8
-rw-r--r--libcxx/include/__algorithm/ranges_all_of.h8
-rw-r--r--libcxx/include/__algorithm/ranges_any_of.h8
-rw-r--r--libcxx/include/__algorithm/ranges_binary_search.h8
-rw-r--r--libcxx/include/__algorithm/ranges_clamp.h65
-rw-r--r--libcxx/include/__algorithm/ranges_copy.h10
-rw-r--r--libcxx/include/__algorithm/ranges_copy_backward.h5
-rw-r--r--libcxx/include/__algorithm/ranges_copy_if.h4
-rw-r--r--libcxx/include/__algorithm/ranges_copy_n.h7
-rw-r--r--libcxx/include/__algorithm/ranges_count.h8
-rw-r--r--libcxx/include/__algorithm/ranges_count_if.h8
-rw-r--r--libcxx/include/__algorithm/ranges_equal.h8
-rw-r--r--libcxx/include/__algorithm/ranges_equal_range.h9
-rw-r--r--libcxx/include/__algorithm/ranges_fill.h4
-rw-r--r--libcxx/include/__algorithm/ranges_fill_n.h4
-rw-r--r--libcxx/include/__algorithm/ranges_find.h8
-rw-r--r--libcxx/include/__algorithm/ranges_find_end.h9
-rw-r--r--libcxx/include/__algorithm/ranges_find_first_of.h8
-rw-r--r--libcxx/include/__algorithm/ranges_find_if.h8
-rw-r--r--libcxx/include/__algorithm/ranges_find_if_not.h8
-rw-r--r--libcxx/include/__algorithm/ranges_for_each.h4
-rw-r--r--libcxx/include/__algorithm/ranges_for_each_n.h4
-rw-r--r--libcxx/include/__algorithm/ranges_generate.h4
-rw-r--r--libcxx/include/__algorithm/ranges_generate_n.h4
-rw-r--r--libcxx/include/__algorithm/ranges_includes.h8
-rw-r--r--libcxx/include/__algorithm/ranges_inplace_merge.h56
-rw-r--r--libcxx/include/__algorithm/ranges_is_heap.h10
-rw-r--r--libcxx/include/__algorithm/ranges_is_heap_until.h10
-rw-r--r--libcxx/include/__algorithm/ranges_is_partitioned.h8
-rw-r--r--libcxx/include/__algorithm/ranges_is_permutation.h89
-rw-r--r--libcxx/include/__algorithm/ranges_is_sorted.h8
-rw-r--r--libcxx/include/__algorithm/ranges_is_sorted_until.h8
-rw-r--r--libcxx/include/__algorithm/ranges_iterator_concept.h8
-rw-r--r--libcxx/include/__algorithm/ranges_lexicographical_compare.h8
-rw-r--r--libcxx/include/__algorithm/ranges_lower_bound.h8
-rw-r--r--libcxx/include/__algorithm/ranges_make_heap.h6
-rw-r--r--libcxx/include/__algorithm/ranges_max.h10
-rw-r--r--libcxx/include/__algorithm/ranges_max_element.h8
-rw-r--r--libcxx/include/__algorithm/ranges_merge.h8
-rw-r--r--libcxx/include/__algorithm/ranges_min.h10
-rw-r--r--libcxx/include/__algorithm/ranges_min_element.h8
-rw-r--r--libcxx/include/__algorithm/ranges_minmax.h11
-rw-r--r--libcxx/include/__algorithm/ranges_minmax_element.h8
-rw-r--r--libcxx/include/__algorithm/ranges_mismatch.h8
-rw-r--r--libcxx/include/__algorithm/ranges_move.h20
-rw-r--r--libcxx/include/__algorithm/ranges_move_backward.h14
-rw-r--r--libcxx/include/__algorithm/ranges_next_permutation.h73
-rw-r--r--libcxx/include/__algorithm/ranges_none_of.h8
-rw-r--r--libcxx/include/__algorithm/ranges_nth_element.h6
-rw-r--r--libcxx/include/__algorithm/ranges_partial_sort.h7
-rw-r--r--libcxx/include/__algorithm/ranges_partial_sort_copy.h24
-rw-r--r--libcxx/include/__algorithm/ranges_partition.h9
-rw-r--r--libcxx/include/__algorithm/ranges_partition_copy.h6
-rw-r--r--libcxx/include/__algorithm/ranges_partition_point.h4
-rw-r--r--libcxx/include/__algorithm/ranges_pop_heap.h6
-rw-r--r--libcxx/include/__algorithm/ranges_prev_permutation.h77
-rw-r--r--libcxx/include/__algorithm/ranges_push_heap.h6
-rw-r--r--libcxx/include/__algorithm/ranges_remove.h8
-rw-r--r--libcxx/include/__algorithm/ranges_remove_copy.h59
-rw-r--r--libcxx/include/__algorithm/ranges_remove_copy_if.h62
-rw-r--r--libcxx/include/__algorithm/ranges_remove_if.h8
-rw-r--r--libcxx/include/__algorithm/ranges_replace.h4
-rw-r--r--libcxx/include/__algorithm/ranges_replace_copy.h73
-rw-r--r--libcxx/include/__algorithm/ranges_replace_copy_if.h76
-rw-r--r--libcxx/include/__algorithm/ranges_replace_if.h4
-rw-r--r--libcxx/include/__algorithm/ranges_reverse.h4
-rw-r--r--libcxx/include/__algorithm/ranges_reverse_copy.h4
-rw-r--r--libcxx/include/__algorithm/ranges_rotate.h71
-rw-r--r--libcxx/include/__algorithm/ranges_rotate_copy.h4
-rw-r--r--libcxx/include/__algorithm/ranges_sample.h74
-rw-r--r--libcxx/include/__algorithm/ranges_search.h9
-rw-r--r--libcxx/include/__algorithm/ranges_search_n.h17
-rw-r--r--libcxx/include/__algorithm/ranges_set_difference.h12
-rw-r--r--libcxx/include/__algorithm/ranges_set_intersection.h6
-rw-r--r--libcxx/include/__algorithm/ranges_set_symmetric_difference.h11
-rw-r--r--libcxx/include/__algorithm/ranges_set_union.h11
-rw-r--r--libcxx/include/__algorithm/ranges_shuffle.h38
-rw-r--r--libcxx/include/__algorithm/ranges_sort.h6
-rw-r--r--libcxx/include/__algorithm/ranges_sort_heap.h6
-rw-r--r--libcxx/include/__algorithm/ranges_stable_partition.h8
-rw-r--r--libcxx/include/__algorithm/ranges_stable_sort.h6
-rw-r--r--libcxx/include/__algorithm/ranges_swap_ranges.h15
-rw-r--r--libcxx/include/__algorithm/ranges_transform.h4
-rw-r--r--libcxx/include/__algorithm/ranges_unique.h51
-rw-r--r--libcxx/include/__algorithm/ranges_unique_copy.h78
-rw-r--r--libcxx/include/__algorithm/ranges_upper_bound.h8
-rw-r--r--libcxx/include/__algorithm/remove.h2
-rw-r--r--libcxx/include/__algorithm/remove_copy.h2
-rw-r--r--libcxx/include/__algorithm/remove_copy_if.h2
-rw-r--r--libcxx/include/__algorithm/remove_if.h2
-rw-r--r--libcxx/include/__algorithm/replace.h2
-rw-r--r--libcxx/include/__algorithm/replace_copy.h2
-rw-r--r--libcxx/include/__algorithm/replace_copy_if.h2
-rw-r--r--libcxx/include/__algorithm/replace_if.h2
-rw-r--r--libcxx/include/__algorithm/reverse.h29
-rw-r--r--libcxx/include/__algorithm/reverse_copy.h2
-rw-r--r--libcxx/include/__algorithm/rotate.h77
-rw-r--r--libcxx/include/__algorithm/rotate_copy.h2
-rw-r--r--libcxx/include/__algorithm/sample.h48
-rw-r--r--libcxx/include/__algorithm/search.h18
-rw-r--r--libcxx/include/__algorithm/search_n.h16
-rw-r--r--libcxx/include/__algorithm/set_difference.h18
-rw-r--r--libcxx/include/__algorithm/set_intersection.h11
-rw-r--r--libcxx/include/__algorithm/set_symmetric_difference.h19
-rw-r--r--libcxx/include/__algorithm/set_union.h19
-rw-r--r--libcxx/include/__algorithm/shuffle.h25
-rw-r--r--libcxx/include/__algorithm/sift_down.h8
-rw-r--r--libcxx/include/__algorithm/sort.h644
-rw-r--r--libcxx/include/__algorithm/sort_heap.h13
-rw-r--r--libcxx/include/__algorithm/stable_partition.h19
-rw-r--r--libcxx/include/__algorithm/stable_sort.h15
-rw-r--r--libcxx/include/__algorithm/swap_ranges.h39
-rw-r--r--libcxx/include/__algorithm/transform.h4
-rw-r--r--libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h62
-rw-r--r--libcxx/include/__algorithm/unique.h47
-rw-r--r--libcxx/include/__algorithm/unique_copy.h146
-rw-r--r--libcxx/include/__algorithm/unwrap_iter.h6
-rw-r--r--libcxx/include/__algorithm/unwrap_range.h97
-rw-r--r--libcxx/include/__algorithm/upper_bound.h6
-rw-r--r--libcxx/include/__assert19
-rw-r--r--libcxx/include/__availability34
-rw-r--r--libcxx/include/__bit/bit_cast.h2
-rw-r--r--libcxx/include/__bit/bit_ceil.h46
-rw-r--r--libcxx/include/__bit/bit_floor.h34
-rw-r--r--libcxx/include/__bit/bit_log2.h34
-rw-r--r--libcxx/include/__bit/bit_width.h33
-rw-r--r--libcxx/include/__bit/blsr.h34
-rw-r--r--libcxx/include/__bit/countl.h104
-rw-r--r--libcxx/include/__bit/countr.h70
-rw-r--r--libcxx/include/__bit/endian.h38
-rw-r--r--libcxx/include/__bit/has_single_bit.h37
-rw-r--r--libcxx/include/__bit/popcount.h61
-rw-r--r--libcxx/include/__bit/rotate.h53
-rw-r--r--libcxx/include/__bit_reference275
-rw-r--r--libcxx/include/__bits162
-rw-r--r--libcxx/include/__bsd_locale_fallbacks.h1
-rw-r--r--libcxx/include/__charconv/chars_format.h10
-rw-r--r--libcxx/include/__charconv/from_chars_result.h4
-rw-r--r--libcxx/include/__charconv/tables.h46
-rw-r--r--libcxx/include/__charconv/to_chars_base_10.h38
-rw-r--r--libcxx/include/__charconv/to_chars_result.h4
-rw-r--r--libcxx/include/__chrono/convert_to_timespec.h1
-rw-r--r--libcxx/include/__chrono/convert_to_tm.h127
-rw-r--r--libcxx/include/__chrono/day.h12
-rw-r--r--libcxx/include/__chrono/duration.h59
-rw-r--r--libcxx/include/__chrono/file_clock.h2
-rw-r--r--libcxx/include/__chrono/formatter.h716
-rw-r--r--libcxx/include/__chrono/hh_mm_ss.h34
-rw-r--r--libcxx/include/__chrono/month.h35
-rw-r--r--libcxx/include/__chrono/month_weekday.h24
-rw-r--r--libcxx/include/__chrono/monthday.h75
-rw-r--r--libcxx/include/__chrono/ostream.h238
-rw-r--r--libcxx/include/__chrono/parser_std_format_spec.h410
-rw-r--r--libcxx/include/__chrono/statically_widen.h52
-rw-r--r--libcxx/include/__chrono/steady_clock.h2
-rw-r--r--libcxx/include/__chrono/system_clock.h2
-rw-r--r--libcxx/include/__chrono/time_point.h44
-rw-r--r--libcxx/include/__chrono/weekday.h38
-rw-r--r--libcxx/include/__chrono/year.h41
-rw-r--r--libcxx/include/__chrono/year_month.h45
-rw-r--r--libcxx/include/__chrono/year_month_day.h74
-rw-r--r--libcxx/include/__chrono/year_month_weekday.h56
-rw-r--r--libcxx/include/__compare/common_comparison_category.h5
-rw-r--r--libcxx/include/__compare/compare_partial_order_fallback.h3
-rw-r--r--libcxx/include/__compare/compare_strong_order_fallback.h3
-rw-r--r--libcxx/include/__compare/compare_three_way_result.h7
-rw-r--r--libcxx/include/__compare/compare_weak_order_fallback.h3
-rw-r--r--libcxx/include/__compare/ordering.h9
-rw-r--r--libcxx/include/__compare/partial_order.h5
-rw-r--r--libcxx/include/__compare/strong_order.h5
-rw-r--r--libcxx/include/__compare/synth_three_way.h2
-rw-r--r--libcxx/include/__compare/three_way_comparable.h3
-rw-r--r--libcxx/include/__compare/weak_order.h4
-rw-r--r--libcxx/include/__concepts/arithmetic.h4
-rw-r--r--libcxx/include/__concepts/assignable.h3
-rw-r--r--libcxx/include/__concepts/class_or_enum.h7
-rw-r--r--libcxx/include/__concepts/common_reference_with.h2
-rw-r--r--libcxx/include/__concepts/common_with.h9
-rw-r--r--libcxx/include/__concepts/constructible.h2
-rw-r--r--libcxx/include/__concepts/convertible_to.h4
-rw-r--r--libcxx/include/__concepts/derived_from.h3
-rw-r--r--libcxx/include/__concepts/destructible.h2
-rw-r--r--libcxx/include/__concepts/different_from.h2
-rw-r--r--libcxx/include/__concepts/equality_comparable.h3
-rw-r--r--libcxx/include/__concepts/invocable.h1
-rw-r--r--libcxx/include/__concepts/movable.h2
-rw-r--r--libcxx/include/__concepts/predicate.h2
-rw-r--r--libcxx/include/__concepts/same_as.h2
-rw-r--r--libcxx/include/__concepts/swappable.h7
-rw-r--r--libcxx/include/__concepts/totally_ordered.h3
-rw-r--r--libcxx/include/__config207
-rw-r--r--libcxx/include/__coroutine/coroutine_handle.h9
-rw-r--r--libcxx/include/__coroutine/coroutine_traits.h8
-rw-r--r--libcxx/include/__coroutine/noop_coroutine_handle.h4
-rw-r--r--libcxx/include/__coroutine/trivial_awaitables.h4
-rw-r--r--libcxx/include/__debug29
-rw-r--r--libcxx/include/__debug_utils/randomize_range.h2
-rw-r--r--libcxx/include/__expected/bad_expected_access.h64
-rw-r--r--libcxx/include/__expected/expected.h973
-rw-r--r--libcxx/include/__expected/unexpect.h32
-rw-r--r--libcxx/include/__expected/unexpected.h122
-rw-r--r--libcxx/include/__filesystem/directory_entry.h19
-rw-r--r--libcxx/include/__filesystem/filesystem_error.h3
-rw-r--r--libcxx/include/__filesystem/path.h67
-rw-r--r--libcxx/include/__filesystem/space_info.h4
-rw-r--r--libcxx/include/__format/buffer.h362
-rw-r--r--libcxx/include/__format/concepts.h49
-rw-r--r--libcxx/include/__format/container_adaptor.h70
-rw-r--r--libcxx/include/__format/escaped_output_table.h1038
-rw-r--r--libcxx/include/__format/extended_grapheme_cluster_table.h1673
-rw-r--r--libcxx/include/__format/format_arg.h40
-rw-r--r--libcxx/include/__format/format_arg_store.h5
-rw-r--r--libcxx/include/__format/format_args.h1
-rw-r--r--libcxx/include/__format/format_context.h88
-rw-r--r--libcxx/include/__format/format_error.h14
-rw-r--r--libcxx/include/__format/format_functions.h661
-rw-r--r--libcxx/include/__format/format_parse_context.h9
-rw-r--r--libcxx/include/__format/format_string.h10
-rw-r--r--libcxx/include/__format/format_to_n_result.h1
-rw-r--r--libcxx/include/__format/formatter.h16
-rw-r--r--libcxx/include/__format/formatter_bool.h4
-rw-r--r--libcxx/include/__format/formatter_char.h13
-rw-r--r--libcxx/include/__format/formatter_floating_point.h108
-rw-r--r--libcxx/include/__format/formatter_integer.h28
-rw-r--r--libcxx/include/__format/formatter_integral.h13
-rw-r--r--libcxx/include/__format/formatter_output.h354
-rw-r--r--libcxx/include/__format/formatter_pointer.h10
-rw-r--r--libcxx/include/__format/formatter_string.h34
-rw-r--r--libcxx/include/__format/formatter_tuple.h178
-rw-r--r--libcxx/include/__format/parser_std_format_spec.h132
-rw-r--r--libcxx/include/__format/range_default_formatter.h201
-rw-r--r--libcxx/include/__format/range_formatter.h255
-rw-r--r--libcxx/include/__format/unicode.h172
-rw-r--r--libcxx/include/__functional/binary_negate.h6
-rw-r--r--libcxx/include/__functional/bind.h28
-rw-r--r--libcxx/include/__functional/boyer_moore_searcher.h2
-rw-r--r--libcxx/include/__functional/default_searcher.h5
-rw-r--r--libcxx/include/__functional/function.h1679
-rw-r--r--libcxx/include/__functional/hash.h76
-rw-r--r--libcxx/include/__functional/invoke.h24
-rw-r--r--libcxx/include/__functional/is_transparent.h3
-rw-r--r--libcxx/include/__functional/mem_fn.h6
-rw-r--r--libcxx/include/__functional/not_fn.h4
-rw-r--r--libcxx/include/__functional/operations.h95
-rw-r--r--libcxx/include/__functional/ranges_operations.h3
-rw-r--r--libcxx/include/__functional/reference_wrapper.h25
-rw-r--r--libcxx/include/__functional/unary_negate.h6
-rw-r--r--libcxx/include/__functional/unwrap_ref.h1
-rw-r--r--libcxx/include/__functional/weak_result_type.h7
-rw-r--r--libcxx/include/__fwd/array.h26
-rw-r--r--libcxx/include/__fwd/get.h115
-rw-r--r--libcxx/include/__fwd/hash.h25
-rw-r--r--libcxx/include/__fwd/memory_resource.h27
-rw-r--r--libcxx/include/__fwd/pair.h25
-rw-r--r--libcxx/include/__fwd/span.h6
-rw-r--r--libcxx/include/__fwd/string.h110
-rw-r--r--libcxx/include/__fwd/string_view.h19
-rw-r--r--libcxx/include/__fwd/subrange.h38
-rw-r--r--libcxx/include/__fwd/tuple.h29
-rw-r--r--libcxx/include/__hash_table147
-rw-r--r--libcxx/include/__iterator/access.h16
-rw-r--r--libcxx/include/__iterator/advance.h22
-rw-r--r--libcxx/include/__iterator/back_insert_iterator.h17
-rw-r--r--libcxx/include/__iterator/bounded_iter.h32
-rw-r--r--libcxx/include/__iterator/common_iterator.h39
-rw-r--r--libcxx/include/__iterator/concepts.h24
-rw-r--r--libcxx/include/__iterator/counted_iterator.h13
-rw-r--r--libcxx/include/__iterator/distance.h15
-rw-r--r--libcxx/include/__iterator/front_insert_iterator.h15
-rw-r--r--libcxx/include/__iterator/incrementable_traits.h11
-rw-r--r--libcxx/include/__iterator/insert_iterator.h16
-rw-r--r--libcxx/include/__iterator/iter_move.h9
-rw-r--r--libcxx/include/__iterator/iter_swap.h13
-rw-r--r--libcxx/include/__iterator/iterator_traits.h49
-rw-r--r--libcxx/include/__iterator/iterator_with_data.h100
-rw-r--r--libcxx/include/__iterator/move_iterator.h65
-rw-r--r--libcxx/include/__iterator/move_sentinel.h2
-rw-r--r--libcxx/include/__iterator/next.h8
-rw-r--r--libcxx/include/__iterator/ostreambuf_iterator.h2
-rw-r--r--libcxx/include/__iterator/prev.h8
-rw-r--r--libcxx/include/__iterator/projected.h3
-rw-r--r--libcxx/include/__iterator/readable_traits.h10
-rw-r--r--libcxx/include/__iterator/reverse_access.h20
-rw-r--r--libcxx/include/__iterator/reverse_iterator.h107
-rw-r--r--libcxx/include/__iterator/segmented_iterator.h79
-rw-r--r--libcxx/include/__iterator/size.h3
-rw-r--r--libcxx/include/__iterator/wrap_iter.h71
-rw-r--r--libcxx/include/__locale142
-rw-r--r--libcxx/include/__memory/addressof.h2
-rw-r--r--libcxx/include/__memory/align.h25
-rw-r--r--libcxx/include/__memory/allocate_at_least.h1
-rw-r--r--libcxx/include/__memory/allocator.h25
-rw-r--r--libcxx/include/__memory/allocator_arg_t.h6
-rw-r--r--libcxx/include/__memory/allocator_destructor.h42
-rw-r--r--libcxx/include/__memory/allocator_traits.h63
-rw-r--r--libcxx/include/__memory/assume_aligned.h2
-rw-r--r--libcxx/include/__memory/builtin_new_allocator.h70
-rw-r--r--libcxx/include/__memory/compressed_pair.h33
-rw-r--r--libcxx/include/__memory/concepts.h9
-rw-r--r--libcxx/include/__memory/construct_at.h28
-rw-r--r--libcxx/include/__memory/destruct_n.h64
-rw-r--r--libcxx/include/__memory/pointer_traits.h68
-rw-r--r--libcxx/include/__memory/ranges_construct_at.h7
-rw-r--r--libcxx/include/__memory/ranges_uninitialized_algorithms.h13
-rw-r--r--libcxx/include/__memory/raw_storage_iterator.h1
-rw-r--r--libcxx/include/__memory/shared_ptr.h224
-rw-r--r--libcxx/include/__memory/swap_allocator.h7
-rw-r--r--libcxx/include/__memory/temp_value.h56
-rw-r--r--libcxx/include/__memory/temporary_buffer.h2
-rw-r--r--libcxx/include/__memory/uninitialized_algorithms.h71
-rw-r--r--libcxx/include/__memory/unique_ptr.h405
-rw-r--r--libcxx/include/__memory/uses_allocator.h2
-rw-r--r--libcxx/include/__memory/uses_allocator_construction.h221
-rw-r--r--libcxx/include/__memory/voidify.h2
-rw-r--r--libcxx/include/__memory_resource/memory_resource.h75
-rw-r--r--libcxx/include/__memory_resource/monotonic_buffer_resource.h120
-rw-r--r--libcxx/include/__memory_resource/polymorphic_allocator.h224
-rw-r--r--libcxx/include/__memory_resource/pool_options.h38
-rw-r--r--libcxx/include/__memory_resource/synchronized_pool_resource.h94
-rw-r--r--libcxx/include/__memory_resource/unsynchronized_pool_resource.h106
-rw-r--r--libcxx/include/__mutex_base2
-rw-r--r--libcxx/include/__node_handle7
-rw-r--r--libcxx/include/__numeric/accumulate.h4
-rw-r--r--libcxx/include/__numeric/adjacent_difference.h4
-rw-r--r--libcxx/include/__numeric/exclusive_scan.h4
-rw-r--r--libcxx/include/__numeric/gcd_lcm.h14
-rw-r--r--libcxx/include/__numeric/inclusive_scan.h6
-rw-r--r--libcxx/include/__numeric/inner_product.h4
-rw-r--r--libcxx/include/__numeric/iota.h2
-rw-r--r--libcxx/include/__numeric/midpoint.h22
-rw-r--r--libcxx/include/__numeric/partial_sum.h4
-rw-r--r--libcxx/include/__numeric/reduce.h6
-rw-r--r--libcxx/include/__numeric/transform_exclusive_scan.h2
-rw-r--r--libcxx/include/__numeric/transform_inclusive_scan.h4
-rw-r--r--libcxx/include/__numeric/transform_reduce.h6
-rw-r--r--libcxx/include/__random/bernoulli_distribution.h4
-rw-r--r--libcxx/include/__random/binomial_distribution.h10
-rw-r--r--libcxx/include/__random/cauchy_distribution.h4
-rw-r--r--libcxx/include/__random/chi_squared_distribution.h4
-rw-r--r--libcxx/include/__random/discard_block_engine.h10
-rw-r--r--libcxx/include/__random/discrete_distribution.h4
-rw-r--r--libcxx/include/__random/exponential_distribution.h4
-rw-r--r--libcxx/include/__random/extreme_value_distribution.h4
-rw-r--r--libcxx/include/__random/fisher_f_distribution.h4
-rw-r--r--libcxx/include/__random/gamma_distribution.h4
-rw-r--r--libcxx/include/__random/generate_canonical.h2
-rw-r--r--libcxx/include/__random/geometric_distribution.h4
-rw-r--r--libcxx/include/__random/independent_bits_engine.h12
-rw-r--r--libcxx/include/__random/is_seed_sequence.h2
-rw-r--r--libcxx/include/__random/is_valid.h2
-rw-r--r--libcxx/include/__random/linear_congruential_engine.h4
-rw-r--r--libcxx/include/__random/log2.h9
-rw-r--r--libcxx/include/__random/mersenne_twister_engine.h12
-rw-r--r--libcxx/include/__random/negative_binomial_distribution.h4
-rw-r--r--libcxx/include/__random/normal_distribution.h40
-rw-r--r--libcxx/include/__random/piecewise_constant_distribution.h4
-rw-r--r--libcxx/include/__random/piecewise_linear_distribution.h4
-rw-r--r--libcxx/include/__random/poisson_distribution.h4
-rw-r--r--libcxx/include/__random/shuffle_order_engine.h42
-rw-r--r--libcxx/include/__random/student_t_distribution.h4
-rw-r--r--libcxx/include/__random/subtract_with_carry_engine.h12
-rw-r--r--libcxx/include/__random/uniform_int_distribution.h23
-rw-r--r--libcxx/include/__random/uniform_real_distribution.h4
-rw-r--r--libcxx/include/__random/weibull_distribution.h4
-rw-r--r--libcxx/include/__ranges/access.h10
-rw-r--r--libcxx/include/__ranges/all.h7
-rw-r--r--libcxx/include/__ranges/as_rvalue_view.h137
-rw-r--r--libcxx/include/__ranges/common_view.h8
-rw-r--r--libcxx/include/__ranges/concepts.h11
-rw-r--r--libcxx/include/__ranges/copyable_box.h8
-rw-r--r--libcxx/include/__ranges/counted.h5
-rw-r--r--libcxx/include/__ranges/dangling.h2
-rw-r--r--libcxx/include/__ranges/data.h8
-rw-r--r--libcxx/include/__ranges/drop_view.h8
-rw-r--r--libcxx/include/__ranges/drop_while_view.h129
-rw-r--r--libcxx/include/__ranges/elements_view.h423
-rw-r--r--libcxx/include/__ranges/empty.h6
-rw-r--r--libcxx/include/__ranges/empty_view.h5
-rw-r--r--libcxx/include/__ranges/enable_view.h7
-rw-r--r--libcxx/include/__ranges/filter_view.h63
-rw-r--r--libcxx/include/__ranges/iota_view.h436
-rw-r--r--libcxx/include/__ranges/istream_view.h149
-rw-r--r--libcxx/include/__ranges/join_view.h138
-rw-r--r--libcxx/include/__ranges/lazy_split_view.h6
-rw-r--r--libcxx/include/__ranges/non_propagating_cache.h6
-rw-r--r--libcxx/include/__ranges/owning_view.h6
-rw-r--r--libcxx/include/__ranges/range_adaptor.h10
-rw-r--r--libcxx/include/__ranges/rbegin.h5
-rw-r--r--libcxx/include/__ranges/ref_view.h10
-rw-r--r--libcxx/include/__ranges/rend.h5
-rw-r--r--libcxx/include/__ranges/reverse_view.h5
-rw-r--r--libcxx/include/__ranges/single_view.h7
-rw-r--r--libcxx/include/__ranges/size.h12
-rw-r--r--libcxx/include/__ranges/split_view.h232
-rw-r--r--libcxx/include/__ranges/subrange.h33
-rw-r--r--libcxx/include/__ranges/take_view.h18
-rw-r--r--libcxx/include/__ranges/take_while_view.h183
-rw-r--r--libcxx/include/__ranges/transform_view.h133
-rw-r--r--libcxx/include/__ranges/view_interface.h13
-rw-r--r--libcxx/include/__ranges/views.h4
-rw-r--r--libcxx/include/__ranges/zip_view.h11
-rw-r--r--libcxx/include/__split_buffer167
-rw-r--r--libcxx/include/__string/char_traits.h549
-rw-r--r--libcxx/include/__thread/poll_with_backoff.h4
-rw-r--r--libcxx/include/__thread/timed_backoff_policy.h1
-rw-r--r--libcxx/include/__threading_support79
-rw-r--r--libcxx/include/__tree73
-rw-r--r--libcxx/include/__tuple550
-rw-r--r--libcxx/include/__tuple_dir/apply_cv.h70
-rw-r--r--libcxx/include/__tuple_dir/make_tuple_types.h84
-rw-r--r--libcxx/include/__tuple_dir/pair_like.h32
-rw-r--r--libcxx/include/__tuple_dir/sfinae_helpers.h196
-rw-r--r--libcxx/include/__tuple_dir/tuple_element.h93
-rw-r--r--libcxx/include/__tuple_dir/tuple_indices.h37
-rw-r--r--libcxx/include/__tuple_dir/tuple_like.h51
-rw-r--r--libcxx/include/__tuple_dir/tuple_like_ext.h44
-rw-r--r--libcxx/include/__tuple_dir/tuple_size.h75
-rw-r--r--libcxx/include/__tuple_dir/tuple_types.h24
-rw-r--r--libcxx/include/__type_traits/add_lvalue_reference.h30
-rw-r--r--libcxx/include/__type_traits/add_pointer.h28
-rw-r--r--libcxx/include/__type_traits/add_rvalue_reference.h31
-rw-r--r--libcxx/include/__type_traits/aligned_storage.h22
-rw-r--r--libcxx/include/__type_traits/aligned_union.h5
-rw-r--r--libcxx/include/__type_traits/alignment_of.h2
-rw-r--r--libcxx/include/__type_traits/apply_cv.h5
-rw-r--r--libcxx/include/__type_traits/can_extract_key.h56
-rw-r--r--libcxx/include/__type_traits/common_reference.h2
-rw-r--r--libcxx/include/__type_traits/common_type.h14
-rw-r--r--libcxx/include/__type_traits/conditional.h13
-rw-r--r--libcxx/include/__type_traits/conjunction.h43
-rw-r--r--libcxx/include/__type_traits/copy_cvref.h4
-rw-r--r--libcxx/include/__type_traits/decay.h18
-rw-r--r--libcxx/include/__type_traits/dependent_type.h25
-rw-r--r--libcxx/include/__type_traits/disjunction.h7
-rw-r--r--libcxx/include/__type_traits/has_virtual_destructor.h11
-rw-r--r--libcxx/include/__type_traits/is_allocator.h36
-rw-r--r--libcxx/include/__type_traits/is_always_bitcastable.h82
-rw-r--r--libcxx/include/__type_traits/is_assignable.h35
-rw-r--r--libcxx/include/__type_traits/is_callable.h2
-rw-r--r--libcxx/include/__type_traits/is_char_like_type.h28
-rw-r--r--libcxx/include/__type_traits/is_class.h2
-rw-r--r--libcxx/include/__type_traits/is_constant_evaluated.h2
-rw-r--r--libcxx/include/__type_traits/is_constructible.h2
-rw-r--r--libcxx/include/__type_traits/is_convertible.h4
-rw-r--r--libcxx/include/__type_traits/is_copy_assignable.h10
-rw-r--r--libcxx/include/__type_traits/is_copy_constructible.h6
-rw-r--r--libcxx/include/__type_traits/is_default_constructible.h5
-rw-r--r--libcxx/include/__type_traits/is_destructible.h4
-rw-r--r--libcxx/include/__type_traits/is_enum.h1
-rw-r--r--libcxx/include/__type_traits/is_floating_point.h2
-rw-r--r--libcxx/include/__type_traits/is_implicitly_default_constructible.h48
-rw-r--r--libcxx/include/__type_traits/is_integral.h2
-rw-r--r--libcxx/include/__type_traits/is_literal_type.h2
-rw-r--r--libcxx/include/__type_traits/is_member_function_pointer.h2
-rw-r--r--libcxx/include/__type_traits/is_member_object_pointer.h2
-rw-r--r--libcxx/include/__type_traits/is_member_pointer.h3
-rw-r--r--libcxx/include/__type_traits/is_move_assignable.h10
-rw-r--r--libcxx/include/__type_traits/is_move_constructible.h3
-rw-r--r--libcxx/include/__type_traits/is_nothrow_assignable.h29
-rw-r--r--libcxx/include/__type_traits/is_nothrow_constructible.h11
-rw-r--r--libcxx/include/__type_traits/is_nothrow_convertible.h2
-rw-r--r--libcxx/include/__type_traits/is_nothrow_copy_assignable.h11
-rw-r--r--libcxx/include/__type_traits/is_nothrow_copy_constructible.h15
-rw-r--r--libcxx/include/__type_traits/is_nothrow_default_constructible.h5
-rw-r--r--libcxx/include/__type_traits/is_nothrow_destructible.h5
-rw-r--r--libcxx/include/__type_traits/is_nothrow_move_assignable.h11
-rw-r--r--libcxx/include/__type_traits/is_nothrow_move_constructible.h13
-rw-r--r--libcxx/include/__type_traits/is_null_pointer.h4
-rw-r--r--libcxx/include/__type_traits/is_pod.h14
-rw-r--r--libcxx/include/__type_traits/is_pointer.h2
-rw-r--r--libcxx/include/__type_traits/is_reference_wrapper.h2
-rw-r--r--libcxx/include/__type_traits/is_referenceable.h18
-rw-r--r--libcxx/include/__type_traits/is_scalar.h1
-rw-r--r--libcxx/include/__type_traits/is_signed.h2
-rw-r--r--libcxx/include/__type_traits/is_specialization.h45
-rw-r--r--libcxx/include/__type_traits/is_standard_layout.h6
-rw-r--r--libcxx/include/__type_traits/is_swappable.h165
-rw-r--r--libcxx/include/__type_traits/is_trivial.h7
-rw-r--r--libcxx/include/__type_traits/is_trivially_assignable.h2
-rw-r--r--libcxx/include/__type_traits/is_trivially_constructible.h2
-rw-r--r--libcxx/include/__type_traits/is_trivially_copy_assignable.h11
-rw-r--r--libcxx/include/__type_traits/is_trivially_copy_constructible.h3
-rw-r--r--libcxx/include/__type_traits/is_trivially_copyable.h2
-rw-r--r--libcxx/include/__type_traits/is_trivially_default_constructible.h5
-rw-r--r--libcxx/include/__type_traits/is_trivially_destructible.h11
-rw-r--r--libcxx/include/__type_traits/is_trivially_move_assignable.h10
-rw-r--r--libcxx/include/__type_traits/is_trivially_move_constructible.h7
-rw-r--r--libcxx/include/__type_traits/is_union.h1
-rw-r--r--libcxx/include/__type_traits/is_unsigned.h3
-rw-r--r--libcxx/include/__type_traits/is_valid_expansion.h2
-rw-r--r--libcxx/include/__type_traits/is_void.h4
-rw-r--r--libcxx/include/__type_traits/make_const_lvalue_ref.h26
-rw-r--r--libcxx/include/__type_traits/make_signed.h30
-rw-r--r--libcxx/include/__type_traits/make_unsigned.h36
-rw-r--r--libcxx/include/__type_traits/maybe_const.h26
-rw-r--r--libcxx/include/__type_traits/negation.h2
-rw-r--r--libcxx/include/__type_traits/noexcept_move_assign_container.h35
-rw-r--r--libcxx/include/__type_traits/promote.h6
-rw-r--r--libcxx/include/__type_traits/rank.h10
-rw-r--r--libcxx/include/__type_traits/remove_all_extents.h15
-rw-r--r--libcxx/include/__type_traits/remove_const.h16
-rw-r--r--libcxx/include/__type_traits/remove_const_ref.h27
-rw-r--r--libcxx/include/__type_traits/remove_cv.h18
-rw-r--r--libcxx/include/__type_traits/remove_cvref.h14
-rw-r--r--libcxx/include/__type_traits/remove_extent.h15
-rw-r--r--libcxx/include/__type_traits/remove_pointer.h15
-rw-r--r--libcxx/include/__type_traits/remove_reference.h15
-rw-r--r--libcxx/include/__type_traits/remove_volatile.h16
-rw-r--r--libcxx/include/__type_traits/result_of.h39
-rw-r--r--libcxx/include/__type_traits/strip_signature.h79
-rw-r--r--libcxx/include/__type_traits/void_t.h4
-rw-r--r--libcxx/include/__utility/as_const.h4
-rw-r--r--libcxx/include/__utility/auto_cast.h2
-rw-r--r--libcxx/include/__utility/cmp.h6
-rw-r--r--libcxx/include/__utility/convert_to_integral.h72
-rw-r--r--libcxx/include/__utility/declval.h2
-rw-r--r--libcxx/include/__utility/exception_guard.h128
-rw-r--r--libcxx/include/__utility/exchange.h5
-rw-r--r--libcxx/include/__utility/forward.h8
-rw-r--r--libcxx/include/__utility/forward_like.h46
-rw-r--r--libcxx/include/__utility/in_place.h7
-rw-r--r--libcxx/include/__utility/integer_sequence.h77
-rw-r--r--libcxx/include/__utility/move.h20
-rw-r--r--libcxx/include/__utility/pair.h250
-rw-r--r--libcxx/include/__utility/rel_ops.h3
-rw-r--r--libcxx/include/__utility/swap.h10
-rw-r--r--libcxx/include/__utility/to_underlying.h2
-rw-r--r--libcxx/include/__utility/transaction.h96
-rw-r--r--libcxx/include/__utility/unreachable.h16
-rw-r--r--libcxx/include/__variant/monostate.h32
-rw-r--r--libcxx/include/__verbose_abort57
-rw-r--r--libcxx/include/algorithm246
-rw-r--r--libcxx/include/any100
-rw-r--r--libcxx/include/array140
-rw-r--r--libcxx/include/atomic220
-rw-r--r--libcxx/include/barrier25
-rw-r--r--libcxx/include/bit200
-rw-r--r--libcxx/include/bitset281
-rw-r--r--libcxx/include/cassert9
-rw-r--r--libcxx/include/cctype8
-rw-r--r--libcxx/include/cerrno9
-rw-r--r--libcxx/include/cfenv9
-rw-r--r--libcxx/include/cfloat9
-rw-r--r--libcxx/include/charconv230
-rw-r--r--libcxx/include/chrono149
-rw-r--r--libcxx/include/cinttypes13
-rw-r--r--libcxx/include/climits9
-rw-r--r--libcxx/include/clocale9
-rw-r--r--libcxx/include/cmath207
-rw-r--r--libcxx/include/codecvt448
-rw-r--r--libcxx/include/compare4
-rw-r--r--libcxx/include/complex771
-rw-r--r--libcxx/include/complex.h12
-rw-r--r--libcxx/include/concepts4
-rw-r--r--libcxx/include/condition_variable8
-rw-r--r--libcxx/include/coroutine11
-rw-r--r--libcxx/include/csetjmp9
-rw-r--r--libcxx/include/csignal6
-rw-r--r--libcxx/include/cstdarg9
-rw-r--r--libcxx/include/cstddef35
-rw-r--r--libcxx/include/cstdint9
-rw-r--r--libcxx/include/cstdio9
-rw-r--r--libcxx/include/cstdlib9
-rw-r--r--libcxx/include/cstring57
-rw-r--r--libcxx/include/ctime9
-rw-r--r--libcxx/include/ctype.h4
-rw-r--r--libcxx/include/cuchar15
-rw-r--r--libcxx/include/cwchar59
-rw-r--r--libcxx/include/cwctype9
-rw-r--r--libcxx/include/deque2131
-rw-r--r--libcxx/include/errno.h4
-rw-r--r--libcxx/include/exception86
-rw-r--r--libcxx/include/expected54
-rw-r--r--libcxx/include/experimental/__memory4
-rw-r--r--libcxx/include/experimental/coroutine31
-rw-r--r--libcxx/include/experimental/deque4
-rw-r--r--libcxx/include/experimental/forward_list4
-rw-r--r--libcxx/include/experimental/functional50
-rw-r--r--libcxx/include/experimental/iterator25
-rw-r--r--libcxx/include/experimental/list4
-rw-r--r--libcxx/include/experimental/map4
-rw-r--r--libcxx/include/experimental/memory_resource50
-rw-r--r--libcxx/include/experimental/propagate_const7
-rw-r--r--libcxx/include/experimental/regex12
-rw-r--r--libcxx/include/experimental/set4
-rw-r--r--libcxx/include/experimental/simd49
-rw-r--r--libcxx/include/experimental/string16
-rw-r--r--libcxx/include/experimental/unordered_map20
-rw-r--r--libcxx/include/experimental/unordered_set4
-rw-r--r--libcxx/include/experimental/vector4
-rw-r--r--libcxx/include/ext/__hash1
-rw-r--r--libcxx/include/ext/hash_map22
-rw-r--r--libcxx/include/ext/hash_set13
-rw-r--r--libcxx/include/fenv.h4
-rw-r--r--libcxx/include/filesystem236
-rw-r--r--libcxx/include/float.h4
-rw-r--r--libcxx/include/format690
-rw-r--r--libcxx/include/forward_list89
-rw-r--r--libcxx/include/fstream63
-rw-r--r--libcxx/include/functional14
-rw-r--r--libcxx/include/future70
-rw-r--r--libcxx/include/initializer_list14
-rw-r--r--libcxx/include/inttypes.h4
-rw-r--r--libcxx/include/iomanip24
-rw-r--r--libcxx/include/ios71
-rw-r--r--libcxx/include/iosfwd26
-rw-r--r--libcxx/include/iostream2
-rw-r--r--libcxx/include/istream41
-rw-r--r--libcxx/include/iterator20
-rw-r--r--libcxx/include/latch12
-rw-r--r--libcxx/include/libcxx.imp45
-rw-r--r--libcxx/include/limits18
-rw-r--r--libcxx/include/limits.h19
-rw-r--r--libcxx/include/list67
-rw-r--r--libcxx/include/locale274
-rw-r--r--libcxx/include/locale.h4
-rw-r--r--libcxx/include/map81
-rw-r--r--libcxx/include/math.h1548
-rw-r--r--libcxx/include/memory349
-rw-r--r--libcxx/include/memory_resource65
-rw-r--r--libcxx/include/module.modulemap.in737
-rw-r--r--libcxx/include/mutex35
-rw-r--r--libcxx/include/new72
-rw-r--r--libcxx/include/numbers8
-rw-r--r--libcxx/include/numeric12
-rw-r--r--libcxx/include/optional191
-rw-r--r--libcxx/include/ostream129
-rw-r--r--libcxx/include/queue15
-rw-r--r--libcxx/include/random31
-rw-r--r--libcxx/include/ranges92
-rw-r--r--libcxx/include/ratio6
-rw-r--r--libcxx/include/regex105
-rw-r--r--libcxx/include/scoped_allocator50
-rw-r--r--libcxx/include/semaphore34
-rw-r--r--libcxx/include/set34
-rw-r--r--libcxx/include/setjmp.h4
-rw-r--r--libcxx/include/shared_mutex55
-rw-r--r--libcxx/include/source_location85
-rw-r--r--libcxx/include/span142
-rw-r--r--libcxx/include/sstream87
-rw-r--r--libcxx/include/stack13
-rw-r--r--libcxx/include/stdatomic.h4
-rw-r--r--libcxx/include/stdbool.h5
-rw-r--r--libcxx/include/stddef.h4
-rw-r--r--libcxx/include/stdexcept22
-rw-r--r--libcxx/include/stdint.h4
-rw-r--r--libcxx/include/stdio.h4
-rw-r--r--libcxx/include/stdlib.h14
-rw-r--r--libcxx/include/streambuf6
-rw-r--r--libcxx/include/string1637
-rw-r--r--libcxx/include/string.h72
-rw-r--r--libcxx/include/string_view399
-rw-r--r--libcxx/include/strstream22
-rw-r--r--libcxx/include/system_error125
-rw-r--r--libcxx/include/tgmath.h14
-rw-r--r--libcxx/include/thread38
-rw-r--r--libcxx/include/tuple288
-rw-r--r--libcxx/include/type_traits291
-rw-r--r--libcxx/include/typeindex27
-rw-r--r--libcxx/include/typeinfo47
-rw-r--r--libcxx/include/uchar.h2
-rw-r--r--libcxx/include/unordered_map71
-rw-r--r--libcxx/include/unordered_set40
-rw-r--r--libcxx/include/utility38
-rw-r--r--libcxx/include/valarray59
-rw-r--r--libcxx/include/variant405
-rw-r--r--libcxx/include/vector1262
-rw-r--r--libcxx/include/version33
-rw-r--r--libcxx/include/wchar.h4
739 files changed, 28945 insertions, 15689 deletions
diff --git a/libcxx/include/__algorithm/adjacent_find.h b/libcxx/include/__algorithm/adjacent_find.h
index 83d8c260f27a..30df4a976f3d 100644
--- a/libcxx/include/__algorithm/adjacent_find.h
+++ b/libcxx/include/__algorithm/adjacent_find.h
@@ -11,8 +11,10 @@
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,25 +22,30 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
+__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ if (__first == __last)
+ return __first;
+ _Iter __i = __first;
+ while (++__i != __last) {
+ if (__pred(*__first, *__i))
+ return __first;
+ __first = __i;
+ }
+ return __i;
+}
+
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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;
+ return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
+ return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/all_of.h b/libcxx/include/__algorithm/all_of.h
index 3af32a577504..284c34ffcda9 100644
--- a/libcxx/include/__algorithm/all_of.h
+++ b/libcxx/include/__algorithm/all_of.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (!__pred(*__first))
diff --git a/libcxx/include/__algorithm/any_of.h b/libcxx/include/__algorithm/any_of.h
index 6fe6a0b6b3c4..fe0882816b9b 100644
--- a/libcxx/include/__algorithm/any_of.h
+++ b/libcxx/include/__algorithm/any_of.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/libcxx/include/__algorithm/binary_search.h b/libcxx/include/__algorithm/binary_search.h
index a44007237850..8f958c2c1ad8 100644
--- a/libcxx/include/__algorithm/binary_search.h
+++ b/libcxx/include/__algorithm/binary_search.h
@@ -23,18 +23,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
{
- using _Comp_ref = typename __comp_ref_type<_Compare>::type;
- __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
+ __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
return __first != __last && !__comp(__value, *__first);
}
template <class _ForwardIterator, class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
diff --git a/libcxx/include/__algorithm/clamp.h b/libcxx/include/__algorithm/clamp.h
index b3762b85a0bc..30ddbdce64a9 100644
--- a/libcxx/include/__algorithm/clamp.h
+++ b/libcxx/include/__algorithm/clamp.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
@@ -33,7 +33,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
{
diff --git a/libcxx/include/__algorithm/comp.h b/libcxx/include/__algorithm/comp.h
index 62c06ae57f23..af8eb7b5d76b 100644
--- a/libcxx/include/__algorithm/comp.h
+++ b/libcxx/include/__algorithm/comp.h
@@ -17,73 +17,47 @@
_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;}
+struct __equal_to {
+ template <class _T1, class _T2>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
+ return __x == __y;
+ }
};
template <class _T1, class _T2 = _T1>
struct __less
{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
};
diff --git a/libcxx/include/__algorithm/comp_ref_type.h b/libcxx/include/__algorithm/comp_ref_type.h
index 4719871461cf..f2338e144688 100644
--- a/libcxx/include/__algorithm/comp_ref_type.h
+++ b/libcxx/include/__algorithm/comp_ref_type.h
@@ -23,11 +23,11 @@ template <class _Compare>
struct __debug_less
{
_Compare &__comp_;
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
__debug_less(_Compare& __c) : __comp_(__c) {}
template <class _Tp, class _Up>
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _Tp& __x, const _Up& __y)
{
bool __r = __comp_(__x, __y);
@@ -37,7 +37,7 @@ struct __debug_less
}
template <class _Tp, class _Up>
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(_Tp& __x, _Up& __y)
{
bool __r = __comp_(__x, __y);
@@ -47,10 +47,10 @@ struct __debug_less
}
template <class _LHS, class _RHS>
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
inline _LIBCPP_INLINE_VISIBILITY
- decltype((void)declval<_Compare&>()(
- declval<_LHS &>(), declval<_RHS &>()))
+ decltype((void)std::declval<_Compare&>()(
+ std::declval<_LHS &>(), std::declval<_RHS &>()))
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
_LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
@@ -59,21 +59,20 @@ struct __debug_less
}
template <class _LHS, class _RHS>
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
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.
+// Pass the comparator by lvalue reference. Or in debug mode, using a
+// debugging wrapper that stores a reference.
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
- typedef __debug_less<_Comp> type;
+template <class _Comp>
+using __comp_ref_type = __debug_less<_Comp>;
#else
- typedef _Comp& type;
+template <class _Comp>
+using __comp_ref_type = _Comp&;
#endif
-};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h
index 5428baa68859..193a6df31656 100644
--- a/libcxx/include/__algorithm/copy.h
+++ b/libcxx/include/__algorithm/copy.h
@@ -9,98 +9,118 @@
#ifndef _LIBCPP___ALGORITHM_COPY_H
#define _LIBCPP___ALGORITHM_COPY_H
-#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/copy_move_common.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/min.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
-#include <__iterator/reverse_iterator.h>
+#include <__iterator/segmented_iterator.h>
+#include <__type_traits/common_type.h>
#include <__utility/move.h>
#include <__utility/pair.h>
-#include <cstring>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
-// copy
+template <class, class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
+
+template <class _AlgPolicy>
+struct __copy_loop {
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ while (__first != __last) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ }
-template <class _InIter, class _Sent, class _OutIter>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) {
- while (__first != __last) {
- *__result = *__first;
- ++__first;
- ++__result;
+ return std::make_pair(std::move(__first), std::move(__result));
}
- return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
-}
-template <class _InValueT,
- class _OutValueT,
- class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
- && is_trivially_copy_assignable<_OutValueT>::value> >
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
- if (__libcpp_is_constant_evaluated()
-// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
-#ifndef _LIBCPP_COMPILER_GCC
- && !is_trivially_copyable<_InValueT>::value
-#endif
- )
- return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result);
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT));
- return std::make_pair(__first + __n, __result + __n);
-}
+ template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) const {
+ using _Traits = __segmented_iterator_traits<_InIter>;
+ auto __sfirst = _Traits::__segment(__first);
+ auto __slast = _Traits::__segment(__last);
+ if (__sfirst == __slast) {
+ auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
+ return std::make_pair(__last, std::move(__iters.second));
+ }
-template <class _InIter, class _OutIter,
- __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value
- && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value
- && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value
- && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value
- && __is_reverse_iterator<_InIter>::value
- && __is_reverse_iterator<_OutIter>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter>
-__copy_impl(_InIter __first, _InIter __last, _OutIter __result) {
- auto __first_base = std::__unwrap_iter(__first.base());
- auto __last_base = std::__unwrap_iter(__last.base());
- auto __result_base = std::__unwrap_iter(__result.base());
- auto __result_first = __result_base - (__first_base - __last_base);
- std::__copy_impl(__last_base, __first_base, __result_first);
- return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first)));
-}
+ __result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
+ ++__sfirst;
+ while (__sfirst != __slast) {
+ __result =
+ std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
+ ++__sfirst;
+ }
+ __result =
+ std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
+ return std::make_pair(__last, std::move(__result));
+ }
-template <class _InIter, class _Sent, class _OutIter,
- __enable_if_t<!(is_copy_constructible<_InIter>::value
- && is_copy_constructible<_Sent>::value
- && is_copy_constructible<_OutIter>::value), int> = 0 >
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
- return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));
-}
+ template <class _InIter,
+ class _OutIter,
+ __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
+ !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) {
+ using _Traits = __segmented_iterator_traits<_OutIter>;
+ using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
-template <class _InIter, class _Sent, class _OutIter,
- __enable_if_t<is_copy_constructible<_InIter>::value
- && is_copy_constructible<_Sent>::value
- && is_copy_constructible<_OutIter>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter>
+ if (__first == __last)
+ return std::make_pair(std::move(__first), std::move(__result));
+
+ auto __local_first = _Traits::__local(__result);
+ auto __segment_iterator = _Traits::__segment(__result);
+ while (true) {
+ auto __local_last = _Traits::__end(__segment_iterator);
+ auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
+ auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
+ __first = std::move(__iters.first);
+
+ if (__first == __last)
+ return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
+
+ __local_first = _Traits::__begin(++__segment_iterator);
+ }
+ }
+};
+
+struct __copy_trivial {
+ // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
+ template <class _In, class _Out,
+ __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+ operator()(_In* __first, _In* __last, _Out* __result) const {
+ return std::__copy_trivial_impl(__first, __last, __result);
+ }
+};
+
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
+pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__copy(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__copy_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
- return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
+ return std::__dispatch_copy_or_move<_AlgPolicy, __copy_loop<_AlgPolicy>, __copy_trivial>(
+ std::move(__first), std::move(__last), std::move(__result));
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
- return std::__copy(__first, __last, __result).second;
+ return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_COPY_H
diff --git a/libcxx/include/__algorithm/copy_backward.h b/libcxx/include/__algorithm/copy_backward.h
index 26b8c4d791fd..bb2a4328781c 100644
--- a/libcxx/include/__algorithm/copy_backward.h
+++ b/libcxx/include/__algorithm/copy_backward.h
@@ -9,53 +9,135 @@
#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
-#include <__algorithm/copy.h>
+#include <__algorithm/copy_move_common.h>
#include <__algorithm/iterator_operations.h>
-#include <__algorithm/ranges_copy.h>
-#include <__algorithm/unwrap_iter.h>
-#include <__concepts/same_as.h>
+#include <__algorithm/min.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
-#include <__iterator/reverse_iterator.h>
-#include <__ranges/subrange.h>
+#include <__iterator/segmented_iterator.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/is_copy_constructible.h>
#include <__utility/move.h>
#include <__utility/pair.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 _AlgPolicy, class _InputIterator, class _OutputIterator,
- __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator>
-__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
- auto __ret = std::__copy(
- __unconstrained_reverse_iterator<_InputIterator>(__last),
- __unconstrained_reverse_iterator<_InputIterator>(__first),
- __unconstrained_reverse_iterator<_OutputIterator>(__result));
- return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base());
-}
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
+__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
+
+template <class _AlgPolicy>
+struct __copy_backward_loop {
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ auto __original_last_iter = __last_iter;
+
+ while (__first != __last_iter) {
+ *--__result = *--__last_iter;
+ }
+
+ return std::make_pair(std::move(__original_last_iter), std::move(__result));
+ }
+
+ template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) const {
+ using _Traits = __segmented_iterator_traits<_InIter>;
+ auto __sfirst = _Traits::__segment(__first);
+ auto __slast = _Traits::__segment(__last);
+ if (__sfirst == __slast) {
+ auto __iters =
+ std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
+ return std::make_pair(__last, __iters.second);
+ }
+
+ __result =
+ std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
+ .second;
+ --__slast;
+ while (__sfirst != __slast) {
+ __result =
+ std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
+ .second;
+ --__slast;
+ }
+ __result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
+ .second;
+ return std::make_pair(__last, std::move(__result));
+ }
+
+ template <class _InIter,
+ class _OutIter,
+ __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
+ !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) {
+ using _Traits = __segmented_iterator_traits<_OutIter>;
+ auto __orig_last = __last;
+ auto __segment_iterator = _Traits::__segment(__result);
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,
- __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
- auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last)));
- auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));
- return std::make_pair(__ret.in.base(), __ret.out.base());
+ // When the range contains no elements, __result might not be a valid iterator
+ if (__first == __last)
+ return std::make_pair(__first, __result);
+
+ auto __local_last = _Traits::__local(__result);
+ while (true) {
+ using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
+
+ auto __local_first = _Traits::__begin(__segment_iterator);
+ auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
+ auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
+ __last -= __size;
+
+ if (__first == __last)
+ return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
+ --__segment_iterator;
+ __local_last = _Traits::__end(__segment_iterator);
+ }
+ }
+};
+
+struct __copy_backward_trivial {
+ // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
+ template <class _In, class _Out,
+ __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+ operator()(_In* __first, _In* __last, _Out* __result) const {
+ return std::__copy_backward_trivial_impl(__first, __last, __result);
+ }
+};
+
+template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
+__copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
+ return std::__dispatch_copy_or_move<_AlgPolicy, __copy_backward_loop<_AlgPolicy>, __copy_backward_trivial>(
+ std::move(__first), std::move(__last), std::move(__result));
}
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2
-copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
- return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+_BidirectionalIterator2
+copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+ _BidirectionalIterator2 __result)
+{
+ static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value &&
+ std::is_copy_constructible<_BidirectionalIterator1>::value, "Iterators must be copy constructible.");
+
+ return std::__copy_backward<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result)).second;
}
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
diff --git a/libcxx/include/__algorithm/copy_if.h b/libcxx/include/__algorithm/copy_if.h
index 9c3cd29e2413..a5938b8719da 100644
--- a/libcxx/include/__algorithm/copy_if.h
+++ b/libcxx/include/__algorithm/copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
diff --git a/libcxx/include/__algorithm/copy_move_common.h b/libcxx/include/__algorithm/copy_move_common.h
new file mode 100644
index 000000000000..b88c14911b9b
--- /dev/null
+++ b/libcxx/include/__algorithm/copy_move_common.h
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_MOVE_COMMON_H
+#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/unwrap_range.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_always_bitcastable.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_trivially_assignable.h>
+#include <__type_traits/is_trivially_copyable.h>
+#include <__type_traits/is_volatile.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Type traits.
+
+template <class _From, class _To>
+struct __can_lower_copy_assignment_to_memmove {
+ static const bool value =
+ // If the types are always bitcastable, it's valid to do a bitwise copy between them.
+ __is_always_bitcastable<_From, _To>::value &&
+ // Reject conversions that wouldn't be performed by the regular built-in assignment (e.g. between arrays).
+ is_trivially_assignable<_To&, const _From&>::value &&
+ // `memmove` doesn't accept `volatile` pointers, make sure the optimization SFINAEs away in that case.
+ !is_volatile<_From>::value &&
+ !is_volatile<_To>::value;
+};
+
+template <class _From, class _To>
+struct __can_lower_move_assignment_to_memmove {
+ static const bool value =
+ __is_always_bitcastable<_From, _To>::value &&
+ is_trivially_assignable<_To&, _From&&>::value &&
+ !is_volatile<_From>::value &&
+ !is_volatile<_To>::value;
+};
+
+// `memmove` algorithms implementation.
+
+template <class _In, class _Out>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) {
+ const size_t __n = static_cast<size_t>(__last - __first);
+ ::__builtin_memmove(__result, __first, __n * sizeof(_Out));
+
+ return std::make_pair(__last, __result + __n);
+}
+
+template <class _In, class _Out>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+__copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) {
+ const size_t __n = static_cast<size_t>(__last - __first);
+ __result -= __n;
+
+ ::__builtin_memmove(__result, __first, __n * sizeof(_Out));
+
+ return std::make_pair(__last, __result);
+}
+
+// Iterator unwrapping and dispatching to the correct overload.
+
+template <class _F1, class _F2>
+struct __overload : _F1, _F2 {
+ using _F1::operator();
+ using _F2::operator();
+};
+
+template <class _InIter, class _Sent, class _OutIter, class = void>
+struct __can_rewrap : false_type {};
+
+template <class _InIter, class _Sent, class _OutIter>
+struct __can_rewrap<_InIter,
+ _Sent,
+ _OutIter,
+ // Note that sentinels are always copy-constructible.
+ __enable_if_t< is_copy_constructible<_InIter>::value &&
+ is_copy_constructible<_OutIter>::value > > : true_type {};
+
+template <class _Algorithm,
+ class _InIter,
+ class _Sent,
+ class _OutIter,
+ __enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
+__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
+ auto __range = std::__unwrap_range(__first, std::move(__last));
+ auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
+ return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
+ std::__rewrap_iter(std::move(__out_first), std::move(__result.second)));
+}
+
+template <class _Algorithm,
+ class _InIter,
+ class _Sent,
+ class _OutIter,
+ __enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
+__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
+ return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
+}
+
+template <class _IterOps, class _InValue, class _OutIter, class = void>
+struct __can_copy_without_conversion : false_type {};
+
+template <class _IterOps, class _InValue, class _OutIter>
+struct __can_copy_without_conversion<
+ _IterOps,
+ _InValue,
+ _OutIter,
+ __enable_if_t<is_same<_InValue, typename _IterOps::template __value_type<_OutIter> >::value> > : true_type {};
+
+template <class _AlgPolicy,
+ class _NaiveAlgorithm,
+ class _OptimizedAlgorithm,
+ class _InIter,
+ class _Sent,
+ class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
+__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) {
+#ifdef _LIBCPP_COMPILER_GCC
+ // GCC doesn't support `__builtin_memmove` during constant evaluation.
+ if (__libcpp_is_constant_evaluated()) {
+ return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
+ }
+#else
+ // In Clang, `__builtin_memmove` only supports fully trivially copyable types (just having trivial copy assignment is
+ // insufficient). Also, conversions are not supported.
+ if (__libcpp_is_constant_evaluated()) {
+ using _InValue = typename _IterOps<_AlgPolicy>::template __value_type<_InIter>;
+ if (!is_trivially_copyable<_InValue>::value ||
+ !__can_copy_without_conversion<_IterOps<_AlgPolicy>, _InValue, _OutIter>::value) {
+ return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
+ }
+ }
+#endif // _LIBCPP_COMPILER_GCC
+
+ using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>;
+ return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
diff --git a/libcxx/include/__algorithm/copy_n.h b/libcxx/include/__algorithm/copy_n.h
index 8b915af63c0d..b08bbdfb9b7e 100644
--- a/libcxx/include/__algorithm/copy_n.h
+++ b/libcxx/include/__algorithm/copy_n.h
@@ -12,6 +12,7 @@
#include <__algorithm/copy.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/convert_to_integral.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_input_iterator<_InputIterator>::value &&
@@ -47,7 +48,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
}
template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_random_access_iterator<_InputIterator>::value,
diff --git a/libcxx/include/__algorithm/count.h b/libcxx/include/__algorithm/count.h
index 5b546934038d..6c8c7fda35df 100644
--- a/libcxx/include/__algorithm/count.h
+++ b/libcxx/include/__algorithm/count.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename iterator_traits<_InputIterator>::difference_type
count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
typename iterator_traits<_InputIterator>::difference_type __r(0);
diff --git a/libcxx/include/__algorithm/count_if.h b/libcxx/include/__algorithm/count_if.h
index 1ec2d83394e1..b96521fe0a85 100644
--- a/libcxx/include/__algorithm/count_if.h
+++ b/libcxx/include/__algorithm/count_if.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename iterator_traits<_InputIterator>::difference_type
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
typename iterator_traits<_InputIterator>::difference_type __r(0);
diff --git a/libcxx/include/__algorithm/equal.h b/libcxx/include/__algorithm/equal.h
index ca1bc6bc5665..cf37f46aaf69 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!__pred(*__first1, *__first2))
@@ -31,16 +31,14 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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>());
+ return std::equal(__first1, __last1, __first2, __equal_to());
}
#if _LIBCPP_STD_VER > 11
template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
@@ -50,7 +48,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fir
}
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
random_access_iterator_tag) {
@@ -61,7 +59,7 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random
}
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __pred) {
return _VSTD::__equal<_BinaryPredicate&>(
@@ -70,13 +68,16 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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());
+ return std::__equal(
+ __first1,
+ __last1,
+ __first2,
+ __last2,
+ __equal_to(),
+ typename iterator_traits<_InputIterator1>::iterator_category(),
+ typename iterator_traits<_InputIterator2>::iterator_category());
}
#endif
diff --git a/libcxx/include/__algorithm/equal_range.h b/libcxx/include/__algorithm/equal_range.h
index b11165baf384..2075b03412e3 100644
--- a/libcxx/include/__algorithm/equal_range.h
+++ b/libcxx/include/__algorithm/equal_range.h
@@ -34,7 +34,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_Iter, _Iter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter>
__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
_Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
@@ -58,19 +58,22 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
"The comparator has to be callable");
static_assert(is_copy_constructible<_ForwardIterator>::value,
"Iterator has to be copy constructible");
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return std::__equal_range<_ClassicAlgPolicy>(
- std::move(__first), std::move(__last), __value, static_cast<_Comp_ref>(__comp), std::__identity());
+ std::move(__first),
+ std::move(__last),
+ __value,
+ static_cast<__comp_ref_type<_Compare> >(__comp),
+ std::__identity());
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
return std::equal_range(
std::move(__first),
diff --git a/libcxx/include/__algorithm/fill.h b/libcxx/include/__algorithm/fill.h
index ec9968fdb8b3..76cf4a1477a6 100644
--- a/libcxx/include/__algorithm/fill.h
+++ b/libcxx/include/__algorithm/fill.h
@@ -20,8 +20,10 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
{
@@ -30,7 +32,7 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, fo
}
template <class _RandomAccessIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
{
@@ -38,7 +40,7 @@ __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& _
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
diff --git a/libcxx/include/__algorithm/fill_n.h b/libcxx/include/__algorithm/fill_n.h
index 7482a4188dd5..fe58c8d64178 100644
--- a/libcxx/include/__algorithm/fill_n.h
+++ b/libcxx/include/__algorithm/fill_n.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/convert_to_integral.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,8 +20,10 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
@@ -30,7 +33,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
}
template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
diff --git a/libcxx/include/__algorithm/find.h b/libcxx/include/__algorithm/find.h
index ab37d81262f0..e51dc9bb160a 100644
--- a/libcxx/include/__algorithm/find.h
+++ b/libcxx/include/__algorithm/find.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
for (; __first != __last; ++__first)
if (*__first == __value)
diff --git a/libcxx/include/__algorithm/find_end.h b/libcxx/include/__algorithm/find_end.h
index 65e9f29b1c1f..e2fee6b3c459 100644
--- a/libcxx/include/__algorithm/find_end.h
+++ b/libcxx/include/__algorithm/find_end.h
@@ -37,7 +37,7 @@ template <
class _Pred,
class _Proj1,
class _Proj2>
-_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Iter1, _Iter1> __find_end_impl(
+_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __find_end_impl(
_Iter1 __first1,
_Sent1 __last1,
_Iter2 __first2,
@@ -91,7 +91,7 @@ template <
class _Sent2,
class _Proj1,
class _Proj2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end(
_Iter1 __first1,
_Sent1 __sent1,
_Iter2 __first2,
@@ -144,7 +144,7 @@ template <
class _Sent2,
class _Proj1,
class _Proj2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end(
_Iter1 __first1,
_Sent1 __sent1,
_Iter2 __first2,
@@ -189,7 +189,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate& __pred) {
@@ -208,7 +208,7 @@ _ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterato
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred) {
@@ -216,12 +216,10 @@ _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2) {
- using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
- using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
- return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+ return std::find_end(__first1, __last1, __first2, __last2, __equal_to());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/find_first_of.h b/libcxx/include/__algorithm/find_first_of.h
index b968329fc318..12f0109a616c 100644
--- a/libcxx/include/__algorithm/find_first_of.h
+++ b/libcxx/include/__algorithm/find_first_of.h
@@ -21,10 +21,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
_ForwardIterator2 __first2,
- _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ _ForwardIterator2 __last2,
+ _BinaryPredicate&& __pred) {
for (; __first1 != __last1; ++__first1)
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
if (__pred(*__first1, *__j))
@@ -33,18 +35,16 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardItera
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _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(
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _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>());
+ return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/find_if.h b/libcxx/include/__algorithm/find_if.h
index aa98171a1f61..f4ef3ac31cfe 100644
--- a/libcxx/include/__algorithm/find_if.h
+++ b/libcxx/include/__algorithm/find_if.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/libcxx/include/__algorithm/find_if_not.h b/libcxx/include/__algorithm/find_if_not.h
index 61ddab0b9805..96c159cf5ed3 100644
--- a/libcxx/include/__algorithm/find_if_not.h
+++ b/libcxx/include/__algorithm/find_if_not.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (!__pred(*__first))
diff --git a/libcxx/include/__algorithm/for_each.h b/libcxx/include/__algorithm/for_each.h
index bfbd37c3a3a4..6564f31cd0e7 100644
--- a/libcxx/include/__algorithm/for_each.h
+++ b/libcxx/include/__algorithm/for_each.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_each(_InputIterator __first,
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function for_each(_InputIterator __first,
_InputIterator __last,
_Function __f) {
for (; __first != __last; ++__first)
diff --git a/libcxx/include/__algorithm/for_each_n.h b/libcxx/include/__algorithm/for_each_n.h
index 2552b40c2781..38d204a11819 100644
--- a/libcxx/include/__algorithm/for_each_n.h
+++ b/libcxx/include/__algorithm/for_each_n.h
@@ -11,6 +11,7 @@
#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
#include <__config>
+#include <__utility/convert_to_integral.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -22,7 +23,7 @@ _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,
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator for_each_n(_InputIterator __first,
_Size __orig_n,
_Function __f) {
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
diff --git a/libcxx/include/__algorithm/generate.h b/libcxx/include/__algorithm/generate.h
index dacbd8c68195..48e21b51e6c4 100644
--- a/libcxx/include/__algorithm/generate.h
+++ b/libcxx/include/__algorithm/generate.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
{
diff --git a/libcxx/include/__algorithm/generate_n.h b/libcxx/include/__algorithm/generate_n.h
index 2650e9e5d8b7..45259989bf0e 100644
--- a/libcxx/include/__algorithm/generate_n.h
+++ b/libcxx/include/__algorithm/generate_n.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_GENERATE_N_H
#include <__config>
+#include <__utility/convert_to_integral.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _OutputIterator, class _Size, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
diff --git a/libcxx/include/__algorithm/half_positive.h b/libcxx/include/__algorithm/half_positive.h
index 7666ef1449c6..74aede2b5668 100644
--- a/libcxx/include/__algorithm/half_positive.h
+++ b/libcxx/include/__algorithm/half_positive.h
@@ -29,7 +29,7 @@ typename enable_if
>::type
__half_positive(_Integral __value)
{
- return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
+ return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2);
}
template <typename _Tp>
diff --git a/libcxx/include/__algorithm/in_found_result.h b/libcxx/include/__algorithm/in_found_result.h
index d43f45cd80ef..3134d6e0df2c 100644
--- a/libcxx/include/__algorithm/in_found_result.h
+++ b/libcxx/include/__algorithm/in_found_result.h
@@ -18,7 +18,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -44,6 +44,6 @@ struct in_found_result {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
diff --git a/libcxx/include/__algorithm/in_fun_result.h b/libcxx/include/__algorithm/in_fun_result.h
index 21efa655063d..3cbb9e12d3b3 100644
--- a/libcxx/include/__algorithm/in_fun_result.h
+++ b/libcxx/include/__algorithm/in_fun_result.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template <class _InIter1, class _Func1>
@@ -42,7 +42,7 @@ struct in_fun_result {
};
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/in_in_out_result.h b/libcxx/include/__algorithm/in_in_out_result.h
index e45fef187e0d..3e747be44d66 100644
--- a/libcxx/include/__algorithm/in_in_out_result.h
+++ b/libcxx/include/__algorithm/in_in_out_result.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -49,7 +49,7 @@ struct in_in_out_result {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/in_in_result.h b/libcxx/include/__algorithm/in_in_result.h
index 39e64ced33b2..2098c188cc9f 100644
--- a/libcxx/include/__algorithm/in_in_result.h
+++ b/libcxx/include/__algorithm/in_in_result.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -46,7 +46,7 @@ struct in_in_result {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/in_out_out_result.h b/libcxx/include/__algorithm/in_out_out_result.h
index 52a883b17627..4046eee57df1 100644
--- a/libcxx/include/__algorithm/in_out_out_result.h
+++ b/libcxx/include/__algorithm/in_out_out_result.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template <class _InIter1, class _OutIter1, class _OutIter2>
@@ -47,7 +47,7 @@ struct in_out_out_result {
};
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/in_out_result.h b/libcxx/include/__algorithm/in_out_result.h
index 47e6f3907943..7f5a0271b4c1 100644
--- a/libcxx/include/__algorithm/in_out_result.h
+++ b/libcxx/include/__algorithm/in_out_result.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -46,7 +46,7 @@ struct in_out_result {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/includes.h b/libcxx/include/__algorithm/includes.h
index c64194a2c826..cc39f275bf44 100644
--- a/libcxx/include/__algorithm/includes.h
+++ b/libcxx/include/__algorithm/includes.h
@@ -25,7 +25,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
_Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {
for (; __first2 != __last2; ++__first1) {
@@ -39,7 +39,7 @@ __includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
}
template <class _InputIterator1, class _InputIterator2, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool includes(
_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
@@ -48,14 +48,18 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
"Comparator has to be callable");
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return std::__includes(
- std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
- static_cast<_Comp_ref>(__comp), __identity(), __identity());
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ static_cast<__comp_ref_type<_Compare> >(__comp),
+ __identity(),
+ __identity());
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
return std::includes(
std::move(__first1),
diff --git a/libcxx/include/__algorithm/inplace_merge.h b/libcxx/include/__algorithm/inplace_merge.h
index cb662e791872..5bbefc94bdf2 100644
--- a/libcxx/include/__algorithm/inplace_merge.h
+++ b/libcxx/include/__algorithm/inplace_merge.h
@@ -23,7 +23,11 @@
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
-#include <memory>
+#include <__memory/destruct_n.h>
+#include <__memory/temporary_buffer.h>
+#include <__memory/unique_ptr.h>
+#include <__utility/pair.h>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -54,18 +58,18 @@ public:
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
};
-template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2,
- class _OutputIterator>
-void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
+ class _InputIterator2, class _Sent2, class _OutputIterator>
+_LIBCPP_HIDE_FROM_ABI
+void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
+ _InputIterator2 __first2, _Sent2 __last2,
+ _OutputIterator __result, _Compare&& __comp)
{
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
{
- // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `move`.
- _VSTD::move(__first1, __last1, __result);
+ std::__move<_AlgPolicy>(__first1, __last1, __result);
return;
}
@@ -84,13 +88,16 @@ void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _AlgPolicy, 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;
+_LIBCPP_HIDE_FROM_ABI
+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)
@@ -98,7 +105,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
- std::__half_inplace_merge<_AlgPolicy, _Compare>(__buff, __p, __middle, __last, __first, __comp);
+ std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);
}
else
{
@@ -108,19 +115,22 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi;
typedef __unconstrained_reverse_iterator<value_type*> _Rv;
typedef __invert<_Compare> _Inverted;
- std::__half_inplace_merge<_AlgPolicy, _Inverted>(_Rv(__p), _Rv(__buff),
+ std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff),
_RBi(__middle), _RBi(__first),
_RBi(__last), _Inverted(__comp));
}
}
template <class _AlgPolicy, 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)
-{
+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) {
using _Ops = _IterOps<_AlgPolicy>;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
@@ -130,7 +140,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
if (__len2 == 0)
return;
if (__len1 <= __buff_size || __len2 <= __buff_size)
- return std::__buffered_inplace_merge<_AlgPolicy, _Compare>
+ return std::__buffered_inplace_merge<_AlgPolicy>
(__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)
@@ -158,8 +168,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
__len21 = __len2 / 2;
__m2 = __middle;
_Ops::advance(__m2, __len21);
- // TODO: replace _ClassicAlgPolicy and __identity with _AlgPolicy and projection
- __m1 = std::__upper_bound<_ClassicAlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
+ __m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
__len11 = _Ops::distance(__first, __m1);
}
else
@@ -181,15 +190,13 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
// [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
// swap middle two partitions
- // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`.
- __middle = _VSTD::rotate(__m1, __middle, __m2);
+ __middle = std::__rotate<_AlgPolicy>(__m1, __middle, __m2).first;
// __len12 and __len21 now have swapped meanings
// merge smaller range with recursive call and larger with tail recursion elimination
if (__len11 + __len21 < __len12 + __len22)
{
- std::__inplace_merge<_AlgPolicy, _Compare>(
+ std::__inplace_merge<_AlgPolicy>(
__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;
@@ -197,9 +204,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
else
{
- std::__inplace_merge<_AlgPolicy, _Compare>(
+ std::__inplace_merge<_AlgPolicy>(
__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;
@@ -208,33 +214,39 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
}
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI
void
-inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp)
+__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 __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
+ difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
difference_type __buf_size = _VSTD::min(__len1, __len2);
// TODO: Remove the use of std::get_temporary_buffer
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
_LIBCPP_SUPPRESS_DEPRECATED_POP
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__inplace_merge<_ClassicAlgPolicy, _Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
- __buf.first, __buf.second);
+ return std::__inplace_merge<_AlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
+ _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
+ std::__inplace_merge<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp));
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
void
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
{
- _VSTD::inplace_merge(__first, __middle, __last,
+ std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last),
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
}
diff --git a/libcxx/include/__algorithm/is_heap.h b/libcxx/include/__algorithm/is_heap.h
index 0d399a09b857..2dcb4a28e8d7 100644
--- a/libcxx/include/__algorithm/is_heap.h
+++ b/libcxx/include/__algorithm/is_heap.h
@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _RandomAccessIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last;
+ return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;
}
template<class _RandomAccessIterator>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
diff --git a/libcxx/include/__algorithm/is_heap_until.h b/libcxx/include/__algorithm/is_heap_until.h
index adb35af887fb..6ed4cb29c423 100644
--- a/libcxx/include/__algorithm/is_heap_until.h
+++ b/libcxx/include/__algorithm/is_heap_until.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _RandomAccessIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -48,15 +48,14 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
}
template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp));
+ return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
}
template<class _RandomAccessIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/is_partitioned.h b/libcxx/include/__algorithm/is_partitioned.h
index b4f421cfc053..ab59d3cce582 100644
--- a/libcxx/include/__algorithm/is_partitioned.h
+++ b/libcxx/include/__algorithm/is_partitioned.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
for (; __first != __last; ++__first)
diff --git a/libcxx/include/__algorithm/is_permutation.h b/libcxx/include/__algorithm/is_permutation.h
index cdd742048412..005445652e9d 100644
--- a/libcxx/include/__algorithm/is_permutation.h
+++ b/libcxx/include/__algorithm/is_permutation.h
@@ -11,10 +11,16 @@
#define _LIBCPP___ALGORITHM_IS_PERMUTATION_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
+#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,140 +28,210 @@
_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;
+template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class = void>
+struct _ConstTimeDistance : false_type {};
- // __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) {
+#if _LIBCPP_STD_VER > 17
+
+template <class _Iter1, class _Sent1, class _Iter2, class _Sent2>
+struct _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2, __enable_if_t<
+ sized_sentinel_for<_Sent1, _Iter1> &&
+ sized_sentinel_for<_Sent2, _Iter2>
+>> : true_type {};
+
+#else
+
+template <class _Iter1, class _Iter2>
+struct _ConstTimeDistance<_Iter1, _Iter1, _Iter2, _Iter2, __enable_if_t<
+ is_same<typename iterator_traits<_Iter1>::iterator_category, random_access_iterator_tag>::value &&
+ is_same<typename iterator_traits<_Iter2>::iterator_category, random_access_iterator_tag>::value
+> > : true_type {};
+
+#endif // _LIBCPP_STD_VER > 17
+
+// Internal functions
+
+// For each element in [f1, l1) see if there are the same number of equal elements in [f2, l2)
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
+ using _D1 = __iter_diff_t<_Iter1>;
+
+ for (auto __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))
+ auto __match = __first1;
+ for (; __match != __i; ++__match) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__match), std::__invoke(__proj1, *__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))
+ for (auto __j = __first2; __j != __last2; ++__j) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj2, *__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))
+ for (auto __j = _IterOps<_AlgPolicy>::next(__i); __j != __last1; ++__j) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj1, *__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>());
+// 2+1 iterators, predicate. Not used by range algorithms.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__is_permutation(_ForwardIterator1 __first1, _Sentinel1 __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
+ using _D1 = __iter_diff_t<_ForwardIterator1>;
+ _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1);
+ if (__l1 == _D1(1))
+ return false;
+ auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __l1);
+
+ return std::__is_permutation_impl<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __identity(), __identity());
}
-#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))
+// 2+2 iterators, predicate, non-constant time `distance`.
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
+ /*_ConstTimeDistance=*/false_type) {
+ // Shorten sequences as much as possible by lopping of any equal prefix.
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
break;
+ ++__first1;
+ ++__first2;
+ }
+
if (__first1 == __last1)
return __first2 == __last2;
- else if (__first2 == __last2)
+ if (__first2 == __last2) // Second range is shorter
return false;
- typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
- _D1 __l1 = _VSTD::distance(__first1, __last1);
+ using _D1 = __iter_diff_t<_Iter1>;
+ _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1);
- typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
- _D2 __l2 = _VSTD::distance(__first2, __last2);
+ using _D2 = __iter_diff_t<_Iter2>;
+ _D2 __l2 = _IterOps<_AlgPolicy>::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;
+ return std::__is_permutation_impl<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
}
-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))
+// 2+2 iterators, predicate, specialization for constant-time `distance` call.
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
+ /*_ConstTimeDistance=*/true_type) {
+ if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
return false;
- return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
- _BinaryPredicate&>(__first1, __last1, __first2, __pred);
+ return std::__is_permutation<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2,
+ /*_ConstTimeDistance=*/false_type());
+}
+
+// 2+2 iterators, predicate
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
+ return std::__is_permutation<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2,
+ _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2>());
}
+// Public interface
+
+// 2+1 iterators, predicate
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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());
+ _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
+ "The predicate has to be callable");
+
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), __pred);
+}
+
+// 2+1 iterators
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ return std::is_permutation(__first1, __last1, __first2, __equal_to());
}
+#if _LIBCPP_STD_VER > 11
+
+// 2+2 iterators
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
+ _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ __equal_to(),
+ __identity(),
+ __identity());
+}
+
+// 2+2 iterators, predicate
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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());
+ _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
+ "The predicate has to be callable");
+
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __identity(), __identity());
}
-#endif
+
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/is_sorted.h b/libcxx/include/__algorithm/is_sorted.h
index 56de95bb31b7..bf44f45764d5 100644
--- a/libcxx/include/__algorithm/is_sorted.h
+++ b/libcxx/include/__algorithm/is_sorted.h
@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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;
+ return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
}
template<class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
{
diff --git a/libcxx/include/__algorithm/is_sorted_until.h b/libcxx/include/__algorithm/is_sorted_until.h
index 338d28508c17..b6683000a069 100644
--- a/libcxx/include/__algorithm/is_sorted_until.h
+++ b/libcxx/include/__algorithm/is_sorted_until.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _ForwardIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
@@ -38,15 +38,14 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __
}
template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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);
+ return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
}
template<class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/iter_swap.h b/libcxx/include/__algorithm/iter_swap.h
index 038859e1361d..44422b5de0f0 100644
--- a/libcxx/include/__algorithm/iter_swap.h
+++ b/libcxx/include/__algorithm/iter_swap.h
@@ -20,10 +20,10 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a,
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a,
_ForwardIterator2 __b)
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
- _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
+ _NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) {
swap(*__a, *__b);
}
diff --git a/libcxx/include/__algorithm/iterator_operations.h b/libcxx/include/__algorithm/iterator_operations.h
index 8307d71214e5..bd3e6f1d38fd 100644
--- a/libcxx/include/__algorithm/iterator_operations.h
+++ b/libcxx/include/__algorithm/iterator_operations.h
@@ -10,16 +10,24 @@
#define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
#include <__algorithm/iter_swap.h>
+#include <__algorithm/ranges_iterator_concept.h>
#include <__config>
#include <__iterator/advance.h>
#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
#include <__iterator/iter_move.h>
#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__iterator/readable_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,16 +37,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy> struct _IterOps;
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
struct _RangeAlgPolicy {};
template <>
struct _IterOps<_RangeAlgPolicy> {
+
+ template <class _Iter>
+ using __value_type = iter_value_t<_Iter>;
+
+ template <class _Iter>
+ using __iterator_category = ranges::__iterator_concept<_Iter>;
+
+ template <class _Iter>
+ using __difference_type = iter_difference_t<_Iter>;
+
static constexpr auto advance = ranges::advance;
static constexpr auto distance = ranges::distance;
static constexpr auto __iter_move = ranges::iter_move;
static constexpr auto iter_swap = ranges::iter_swap;
static constexpr auto next = ranges::next;
+ static constexpr auto prev = ranges::prev;
static constexpr auto __advance_to = ranges::advance;
};
@@ -49,64 +68,103 @@ struct _ClassicAlgPolicy {};
template <>
struct _IterOps<_ClassicAlgPolicy> {
+ template <class _Iter>
+ using __value_type = typename iterator_traits<_Iter>::value_type;
+
+ template <class _Iter>
+ using __iterator_category = typename iterator_traits<_Iter>::iterator_category;
+
+ template <class _Iter>
+ using __difference_type = typename iterator_traits<_Iter>::difference_type;
+
// advance
template <class _Iter, class _Distance>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
static void advance(_Iter& __iter, _Distance __count) {
std::advance(__iter, __count);
}
// distance
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {
return std::distance(__first, __last);
}
+ template <class _Iter>
+ using __deref_t = decltype(*std::declval<_Iter&>());
+
+ template <class _Iter>
+ using __move_t = decltype(std::move(*std::declval<_Iter&>()));
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+ static void __validate_iter_reference() {
+ static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__remove_cvref_t<_Iter> >::reference>::value,
+ "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
+ "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
+ "and can lead to dangling reference issues at runtime, so we are flagging this.");
+ }
+
// iter_move
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
- // Declaring the return type is necessary for C++03, so we basically mirror what `decltype(auto)` would deduce.
- static __enable_if_t<
- is_reference<typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
- typename remove_reference< typename iterator_traits<__uncvref_t<_Iter> >::reference >::type&&>
- __iter_move(_Iter&& __i) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
+ // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
+ // that the C++03 mode doesn't support `decltype(auto)` as the return type.
+ __enable_if_t<
+ is_reference<__deref_t<_Iter> >::value,
+ __move_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
return std::move(*std::forward<_Iter>(__i));
}
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
- // Declaring the return type is necessary for C++03, so we basically mirror what `decltype(auto)` would deduce.
- static __enable_if_t<
- !is_reference<typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
- typename iterator_traits<__uncvref_t<_Iter> >::reference>
- __iter_move(_Iter&& __i) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
+ // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
+ // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
+ // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
+ __enable_if_t<
+ !is_reference<__deref_t<_Iter> >::value,
+ __deref_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
return *std::forward<_Iter>(__i);
}
// iter_swap
template <class _Iter1, class _Iter2>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
}
// next
template <class _Iterator>
- _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
_Iterator next(_Iterator, _Iterator __last) {
return __last;
}
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
- __uncvref_t<_Iter> next(_Iter&& __it,
- typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
+ __remove_cvref_t<_Iter> next(_Iter&& __it,
+ typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
return std::next(std::forward<_Iter>(__it), __n);
}
+ // prev
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
+ __remove_cvref_t<_Iter> prev(_Iter&& __iter,
+ typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
+ return std::prev(std::forward<_Iter>(__iter), __n);
+ }
+
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
void __advance_to(_Iter& __first, _Iter __last) {
__first = __last;
}
diff --git a/libcxx/include/__algorithm/lexicographical_compare.h b/libcxx/include/__algorithm/lexicographical_compare.h
index 30ddf2408120..0a13c5dd31c8 100644
--- a/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/libcxx/include/__algorithm/lexicographical_compare.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _InputIterator1, class _InputIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
{
@@ -37,18 +37,17 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
template <class _InputIterator1, class _InputIterator2, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ return _VSTD::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);
}
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
diff --git a/libcxx/include/__algorithm/lower_bound.h b/libcxx/include/__algorithm/lower_bound.h
index 2c92f715265a..2648982ea506 100644
--- a/libcxx/include/__algorithm/lower_bound.h
+++ b/libcxx/include/__algorithm/lower_bound.h
@@ -29,7 +29,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
@@ -48,7 +48,7 @@ _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Com
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
"The comparator has to be callable");
@@ -57,7 +57,7 @@ _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last,
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
return std::lower_bound(__first, __last, __value,
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
diff --git a/libcxx/include/__algorithm/make_heap.h b/libcxx/include/__algorithm/make_heap.h
index bf9dd96756af..d66cfe2e5fc9 100644
--- a/libcxx/include/__algorithm/make_heap.h
+++ b/libcxx/include/__algorithm/make_heap.h
@@ -24,29 +24,28 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
- using _CompRef = typename __comp_ref_type<_Compare>::type;
- _CompRef __comp_ref = __comp;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
+ __comp_ref_type<_Compare> __comp_ref = __comp;
using difference_type = typename iterator_traits<_RandomAccessIterator>::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) {
- std::__sift_down<_AlgPolicy, _CompRef>(__first, __comp_ref, __n, __first + __start);
+ std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start);
}
}
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
std::make_heap(std::move(__first), std::move(__last),
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/make_projected.h b/libcxx/include/__algorithm/make_projected.h
index 64fc3dfb6a12..87d4d59042c6 100644
--- a/libcxx/include/__algorithm/make_projected.h
+++ b/libcxx/include/__algorithm/make_projected.h
@@ -14,51 +14,91 @@
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace ranges {
-
template <class _Pred, class _Proj>
-_LIBCPP_HIDE_FROM_ABI constexpr static
-decltype(auto) __make_projected_pred(_Pred& __pred, _Proj& __proj) {
- if constexpr (same_as<decay_t<_Proj>, identity> && !is_member_pointer_v<decay_t<_Pred>>) {
- // Avoid creating the lambda and just use the pristine predicate -- for certain algorithms, this would enable
- // optimizations that rely on the type of the predicate.
- return __pred;
+struct _ProjectedPred {
+ _Pred& __pred; // Can be a unary or a binary predicate.
+ _Proj& __proj;
+
+ _LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {}
+
+ template <class _Tp>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_Tp&& __v) const {
+ return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
+ }
- } else {
- return [&](auto&& __x) {
- return std::invoke(__pred, std::invoke(__proj, std::forward<decltype(__x)>(__x)));
- };
+ template <class _T1, class _T2>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const {
+ return std::__invoke(__pred,
+ std::__invoke(__proj, std::forward<_T1>(__lhs)),
+ std::__invoke(__proj, std::forward<_T2>(__rhs)));
}
-}
-template <class _Comp, class _Proj>
-_LIBCPP_HIDE_FROM_ABI constexpr static
-decltype(auto) __make_projected_comp(_Comp& __comp, _Proj& __proj) {
- if constexpr (same_as<decay_t<_Proj>, identity> && !is_member_pointer_v<decay_t<_Comp>>) {
- // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
- // optimizations that rely on the type of the comparator.
- return __comp;
+};
- } else {
- return [&](auto&& __lhs, auto&& __rhs) {
- return std::invoke(__comp,
- std::invoke(__proj, std::forward<decltype(__lhs)>(__lhs)),
- std::invoke(__proj, std::forward<decltype(__rhs)>(__rhs)));
- };
- }
+template <class _Pred, class _Proj, class = void>
+struct __can_use_pristine_comp : false_type {};
+
+template <class _Pred, class _Proj>
+struct __can_use_pristine_comp<_Pred, _Proj, __enable_if_t<
+ !is_member_pointer<typename decay<_Pred>::type>::value && (
+#if _LIBCPP_STD_VER > 17
+ is_same<typename decay<_Proj>::type, identity>::value ||
+#endif
+ is_same<typename decay<_Proj>::type, __identity>::value
+ )
+> > : true_type {};
+
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ !__can_use_pristine_comp<_Pred, _Proj>::value,
+ _ProjectedPred<_Pred, _Proj>
+>
+__make_projected(_Pred& __pred, _Proj& __proj) {
+ return _ProjectedPred<_Pred, _Proj>(__pred, __proj);
+}
+
+// Avoid creating the functor and just use the pristine comparator -- for certain algorithms, this would enable
+// optimizations that rely on the type of the comparator. Additionally, this results in less layers of indirection in
+// the call stack when the comparator is invoked, even in an unoptimized build.
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ __can_use_pristine_comp<_Pred, _Proj>::value,
+ _Pred&
+>
+__make_projected(_Pred& __pred, _Proj&) {
+ return __pred;
}
+_LIBCPP_END_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
template <class _Comp, class _Proj1, class _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr static
decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
@@ -81,6 +121,6 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __p
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
diff --git a/libcxx/include/__algorithm/max.h b/libcxx/include/__algorithm/max.h
index 345b235a2193..a08a3fc59bda 100644
--- a/libcxx/include/__algorithm/max.h
+++ b/libcxx/include/__algorithm/max.h
@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -35,7 +35,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
@@ -46,17 +46,16 @@ max(const _Tp& __a, const _Tp& __b)
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_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);
+ return *_VSTD::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
max(initializer_list<_Tp> __t)
{
diff --git a/libcxx/include/__algorithm/max_element.h b/libcxx/include/__algorithm/max_element.h
index 795ec8e1ddc1..6ac310619bf9 100644
--- a/libcxx/include/__algorithm/max_element.h
+++ b/libcxx/include/__algorithm/max_element.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _ForwardIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -37,16 +37,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
}
template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _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);
+ return _VSTD::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::max_element(__first, __last,
diff --git a/libcxx/include/__algorithm/merge.h b/libcxx/include/__algorithm/merge.h
index 48360ed5b445..e54e430bcb6a 100644
--- a/libcxx/include/__algorithm/merge.h
+++ b/libcxx/include/__algorithm/merge.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
__merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
@@ -46,17 +46,16 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_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);
+ return _VSTD::__merge<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
diff --git a/libcxx/include/__algorithm/min.h b/libcxx/include/__algorithm/min.h
index 3d8c73d78f11..2882485ad76f 100644
--- a/libcxx/include/__algorithm/min.h
+++ b/libcxx/include/__algorithm/min.h
@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -35,7 +35,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
min(const _Tp& __a, const _Tp& __b)
{
@@ -46,17 +46,16 @@ min(const _Tp& __a, const _Tp& __b)
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_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);
+ return *_VSTD::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
min(initializer_list<_Tp> __t)
{
diff --git a/libcxx/include/__algorithm/min_element.h b/libcxx/include/__algorithm/min_element.h
index 17b242c341e6..c0706fe9e44d 100644
--- a/libcxx/include/__algorithm/min_element.h
+++ b/libcxx/include/__algorithm/min_element.h
@@ -25,7 +25,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Comp, class _Iter, class _Sent, class _Proj>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
if (__first == __last)
return __first;
@@ -39,14 +39,14 @@ _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
}
template <class _Comp, class _Iter, class _Sent>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {
auto __proj = __identity();
return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);
}
template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -54,12 +54,11 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
"The comparator has to be callable");
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp);
+ return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::min_element(__first, __last,
diff --git a/libcxx/include/__algorithm/min_max_result.h b/libcxx/include/__algorithm/min_max_result.h
index ca77dcc5725a..4be39992b42c 100644
--- a/libcxx/include/__algorithm/min_max_result.h
+++ b/libcxx/include/__algorithm/min_max_result.h
@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -47,7 +47,7 @@ struct min_max_result {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/minmax.h b/libcxx/include/__algorithm/minmax.h
index 7e10b8b8350c..6ef0a777083f 100644
--- a/libcxx/include/__algorithm/minmax.h
+++ b/libcxx/include/__algorithm/minmax.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -35,7 +35,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
@@ -45,7 +45,7 @@ minmax(const _Tp& __a, const _Tp& __b)
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
__identity __proj;
@@ -55,7 +55,7 @@ pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t)
{
diff --git a/libcxx/include/__algorithm/minmax_element.h b/libcxx/include/__algorithm/minmax_element.h
index cf67184e0b4c..caa963e112e1 100644
--- a/libcxx/include/__algorithm/minmax_element.h
+++ b/libcxx/include/__algorithm/minmax_element.h
@@ -32,14 +32,14 @@ public:
_MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(_Iter& __it1, _Iter& __it2) {
return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
}
};
template <class _Iter, class _Sent, class _Proj, class _Comp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
@@ -79,7 +79,7 @@ pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __c
}
template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -91,7 +91,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
}
diff --git a/libcxx/include/__algorithm/mismatch.h b/libcxx/include/__algorithm/mismatch.h
index f2011faf2f9a..600e2cdd3da4 100644
--- a/libcxx/include/__algorithm/mismatch.h
+++ b/libcxx/include/__algorithm/mismatch.h
@@ -23,7 +23,7 @@ _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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!__pred(*__first1, *__first2))
@@ -33,17 +33,15 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 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>());
+ return std::mismatch(__first1, __last1, __first2, __equal_to());
}
#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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __pred) {
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
@@ -54,11 +52,9 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 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>());
+ return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
}
#endif
diff --git a/libcxx/include/__algorithm/move.h b/libcxx/include/__algorithm/move.h
index 0b08d31c176e..ac95bda7b61f 100644
--- a/libcxx/include/__algorithm/move.h
+++ b/libcxx/include/__algorithm/move.h
@@ -9,107 +9,122 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_H
#define _LIBCPP___ALGORITHM_MOVE_H
-#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/copy_move_common.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/min.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
-#include <__iterator/reverse_iterator.h>
+#include <__iterator/segmented_iterator.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/is_copy_constructible.h>
#include <__utility/move.h>
#include <__utility/pair.h>
-#include <cstring>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
-// move
+_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _InIter, class _Sent, class _OutIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
- while (__first != __last) {
- *__result = std::move(*__first);
- ++__first;
- ++__result;
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+__move(_InIter __first, _Sent __last, _OutIter __result);
+
+template <class _AlgPolicy>
+struct __move_loop {
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ while (__first != __last) {
+ *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
+ ++__first;
+ ++__result;
+ }
+ return std::make_pair(std::move(__first), std::move(__result));
}
- return std::make_pair(std::move(__first), std::move(__result));
-}
-template <class _InType,
- class _OutType,
- class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
- && is_trivially_move_assignable<_OutType>::value> >
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
- if (__libcpp_is_constant_evaluated()
-// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
-#ifndef _LIBCPP_COMPILER_GCC
- && !is_trivially_copyable<_InType>::value
-#endif
- )
- return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
- const size_t __n = static_cast<size_t>(__last - __first);
- ::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
- return std::make_pair(__first + __n, __result + __n);
-}
-
-template <class>
-struct __is_trivially_move_assignable_unwrapped_impl : false_type {};
-
-template <class _Type>
-struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};
-
-template <class _Iter>
-struct __is_trivially_move_assignable_unwrapped
- : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
-
-template <class _InIter,
- class _OutIter,
- __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
- typename iterator_traits<_OutIter>::value_type>::value
- && __is_cpp17_contiguous_iterator<_InIter>::value
- && __is_cpp17_contiguous_iterator<_OutIter>::value
- && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
-pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >
-__move_impl(reverse_iterator<_InIter> __first,
- reverse_iterator<_InIter> __last,
- reverse_iterator<_OutIter> __result) {
- auto __first_base = std::__unwrap_iter(__first.base());
- auto __last_base = std::__unwrap_iter(__last.base());
- auto __result_base = std::__unwrap_iter(__result.base());
- auto __result_first = __result_base - (__first_base - __last_base);
- std::__move_impl(__last_base, __first_base, __result_first);
- return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
-}
+ template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) const {
+ using _Traits = __segmented_iterator_traits<_InIter>;
+ auto __sfirst = _Traits::__segment(__first);
+ auto __slast = _Traits::__segment(__last);
+ if (__sfirst == __slast) {
+ auto __iters = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
+ return std::make_pair(__last, std::move(__iters.second));
+ }
+
+ __result = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
+ ++__sfirst;
+ while (__sfirst != __slast) {
+ __result =
+ std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
+ ++__sfirst;
+ }
+ __result =
+ std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
+ return std::make_pair(__last, std::move(__result));
+ }
-template <class _InIter, class _Sent, class _OutIter>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-__enable_if_t<is_copy_constructible<_InIter>::value
- && is_copy_constructible<_Sent>::value
- && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
-__move(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
- return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
-}
+ template <class _InIter,
+ class _OutIter,
+ __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
+ !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) {
+ using _Traits = __segmented_iterator_traits<_OutIter>;
+ using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
+
+ if (__first == __last)
+ return std::make_pair(std::move(__first), std::move(__result));
+
+ auto __local_first = _Traits::__local(__result);
+ auto __segment_iterator = _Traits::__segment(__result);
+ while (true) {
+ auto __local_last = _Traits::__end(__segment_iterator);
+ auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
+ auto __iters = std::__move<_AlgPolicy>(__first, __first + __size, __local_first);
+ __first = std::move(__iters.first);
+
+ if (__first == __last)
+ return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
+
+ __local_first = _Traits::__begin(++__segment_iterator);
+ }
+ }
+};
+
+struct __move_trivial {
+ // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
+ template <class _In, class _Out,
+ __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+ operator()(_In* __first, _In* __last, _Out* __result) const {
+ return std::__copy_trivial_impl(__first, __last, __result);
+ }
+};
-template <class _InIter, class _Sent, class _OutIter>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-__enable_if_t<!is_copy_constructible<_InIter>::value
- || !is_copy_constructible<_Sent>::value
- || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
__move(_InIter __first, _Sent __last, _OutIter __result) {
- return std::__move_impl(std::move(__first), std::move(__last), std::move(__result));
+ return std::__dispatch_copy_or_move<_AlgPolicy, __move_loop<_AlgPolicy>, __move_trivial>(
+ std::move(__first), std::move(__last), std::move(__result));
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
- return std::__move(__first, __last, __result).second;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
+move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ static_assert(is_copy_constructible<_InputIterator>::value, "Iterators has to be copy constructible.");
+ static_assert(is_copy_constructible<_OutputIterator>::value, "The output iterator has to be copy constructible.");
+
+ return std::__move<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
}
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_MOVE_H
diff --git a/libcxx/include/__algorithm/move_backward.h b/libcxx/include/__algorithm/move_backward.h
index a56f6b826ce3..d4f013be6807 100644
--- a/libcxx/include/__algorithm/move_backward.h
+++ b/libcxx/include/__algorithm/move_backward.h
@@ -9,71 +9,131 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
-#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/copy_move_common.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/min.h>
#include <__config>
+#include <__iterator/segmented_iterator.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/is_copy_constructible.h>
#include <__utility/move.h>
-#include <cstring>
-#include <type_traits>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _InputIterator, class _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 _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
+__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __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 _AlgPolicy>
+struct __move_backward_loop {
+ template <class _InIter, class _Sent, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ auto __original_last_iter = __last_iter;
+
+ while (__first != __last_iter) {
+ *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last_iter);
+ }
+
+ return std::make_pair(std::move(__original_last_iter), std::move(__result));
+ }
+
+ template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) const {
+ using _Traits = __segmented_iterator_traits<_InIter>;
+ auto __sfirst = _Traits::__segment(__first);
+ auto __slast = _Traits::__segment(__last);
+ if (__sfirst == __slast) {
+ auto __iters =
+ std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
+ return std::make_pair(__last, __iters.second);
+ }
+
+ __result =
+ std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
+ .second;
+ --__slast;
+ while (__sfirst != __slast) {
+ __result =
+ std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
+ .second;
+ --__slast;
+ }
+ __result = std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
+ .second;
+ return std::make_pair(__last, std::move(__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));
+ template <class _InIter,
+ class _OutIter,
+ __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
+ !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
+ operator()(_InIter __first, _InIter __last, _OutIter __result) {
+ using _Traits = __segmented_iterator_traits<_OutIter>;
+ using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
+
+ // When the range contains no elements, __result might not be a valid iterator
+ if (__first == __last)
+ return std::make_pair(__first, __result);
+
+ auto __orig_last = __last;
+
+ auto __local_last = _Traits::__local(__result);
+ auto __segment_iterator = _Traits::__segment(__result);
+ while (true) {
+ auto __local_first = _Traits::__begin(__segment_iterator);
+ auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
+ auto __iter = std::__move_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
+ __last -= __size;
+
+ if (__first == __last)
+ return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
+
+ __local_last = _Traits::__end(--__segment_iterator);
}
- return __result;
+ }
+};
+
+struct __move_backward_trivial {
+ // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
+ template <class _In, class _Out,
+ __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
+ operator()(_In* __first, _In* __last, _Out* __result) const {
+ return std::__copy_backward_trivial_impl(__first, __last, __result);
+ }
+};
+
+template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
+__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
+ static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value &&
+ std::is_copy_constructible<_BidirectionalIterator1>::value, "Iterators must be copy constructible.");
+
+ return std::__dispatch_copy_or_move<_AlgPolicy, __move_backward_loop<_AlgPolicy>, __move_backward_trivial>(
+ std::move(__first), std::move(__last), std::move(__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)));
- }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
+move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
+ return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
}
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
diff --git a/libcxx/include/__algorithm/next_permutation.h b/libcxx/include/__algorithm/next_permutation.h
index 05e56f4a17ff..73e8b99ab90b 100644
--- a/libcxx/include/__algorithm/next_permutation.h
+++ b/libcxx/include/__algorithm/next_permutation.h
@@ -11,10 +11,12 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/reverse.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,44 +24,48 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator, bool>
+__next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
{
- _BidirectionalIterator __i = __last;
+ using _Result = pair<_BidirectionalIterator, bool>;
+
+ _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ _BidirectionalIterator __i = __last_iter;
if (__first == __last || __first == --__i)
- return false;
+ return _Result(std::move(__last_iter), false);
+
while (true)
{
_BidirectionalIterator __ip1 = __i;
if (__comp(*--__i, *__ip1))
{
- _BidirectionalIterator __j = __last;
+ _BidirectionalIterator __j = __last_iter;
while (!__comp(*__i, *--__j))
;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
+ _IterOps<_AlgPolicy>::iter_swap(__i, __j);
+ std::__reverse<_AlgPolicy>(__ip1, __last_iter);
+ return _Result(std::move(__last_iter), true);
}
if (__i == __first)
{
- _VSTD::reverse(__first, __last);
- return false;
+ std::__reverse<_AlgPolicy>(__first, __last_iter);
+ return _Result(std::move(__last_iter), false);
}
}
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ return std::__next_permutation<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)).second;
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
diff --git a/libcxx/include/__algorithm/none_of.h b/libcxx/include/__algorithm/none_of.h
index b34b1e00ddb8..19357eb2367c 100644
--- a/libcxx/include/__algorithm/none_of.h
+++ b/libcxx/include/__algorithm/none_of.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/libcxx/include/__algorithm/nth_element.h b/libcxx/include/__algorithm/nth_element.h
index 688398dee814..9fdfb2cae64c 100644
--- a/libcxx/include/__algorithm/nth_element.h
+++ b/libcxx/include/__algorithm/nth_element.h
@@ -26,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
_RandomAccessIterator __m, _Compare __comp)
{
@@ -42,7 +42,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
{
using _Ops = _IterOps<_AlgPolicy>;
@@ -223,7 +223,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
}
template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
_Compare& __comp) {
if (__nth == __last)
@@ -231,8 +231,7 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
std::__debug_randomize_range<_AlgPolicy>(__first, __last);
- using _Comp_ref = typename __comp_ref_type<_Compare>::type;
- std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp);
+ std::__nth_element<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __nth, __last, __comp);
std::__debug_randomize_range<_AlgPolicy>(__first, __nth);
if (__nth != __last) {
@@ -241,14 +240,14 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
_Compare __comp) {
std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {
std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename
iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/partial_sort.h b/libcxx/include/__algorithm/partial_sort.h
index 24016e5cf5a5..e0812affe6b5 100644
--- a/libcxx/include/__algorithm/partial_sort.h
+++ b/libcxx/include/__algorithm/partial_sort.h
@@ -29,14 +29,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_RandomAccessIterator __partial_sort_impl(
- _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare __comp) {
+ _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
if (__first == __middle) {
return _IterOps<_AlgPolicy>::next(__middle, __last);
}
- std::__make_heap<_AlgPolicy, _Compare>(__first, __middle, __comp);
+ std::__make_heap<_AlgPolicy>(__first, __middle, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
_RandomAccessIterator __i = __middle;
@@ -45,17 +45,16 @@ _RandomAccessIterator __partial_sort_impl(
if (__comp(*__i, *__first))
{
_IterOps<_AlgPolicy>::iter_swap(__i, __first);
- std::__sift_down<_AlgPolicy, _Compare>(__first, __comp, __len, __first);
+ std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
}
-
}
- std::__sort_heap<_AlgPolicy, _Compare>(std::move(__first), std::move(__middle), __comp);
+ std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
return __i;
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,
_Compare& __comp) {
if (__first == __middle)
@@ -63,8 +62,8 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
std::__debug_randomize_range<_AlgPolicy>(__first, __last);
- using _Comp_ref = typename __comp_ref_type<_Compare>::type;
- auto __last_iter = std::__partial_sort_impl<_AlgPolicy, _Comp_ref>(__first, __middle, __last, __comp);
+ auto __last_iter =
+ std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
@@ -72,7 +71,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_Compare __comp)
@@ -84,7 +83,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
diff --git a/libcxx/include/__algorithm/partial_sort_copy.h b/libcxx/include/__algorithm/partial_sort_copy.h
index 3556764e652d..1aba07105dc8 100644
--- a/libcxx/include/__algorithm/partial_sort_copy.h
+++ b/libcxx/include/__algorithm/partial_sort_copy.h
@@ -13,10 +13,16 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_heap.h>
+#include <__algorithm/make_projected.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,42 +30,51 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _AlgPolicy, 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)
+template <class _AlgPolicy, class _Compare,
+ class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
+ class _Proj1, class _Proj2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _RandomAccessIterator>
+__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
+ _RandomAccessIterator __result_first, _Sentinel2 __result_last,
+ _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
{
_RandomAccessIterator __r = __result_first;
+ auto&& __projected_comp = std::__make_projected(__comp, __proj2);
+
if (__r != __result_last)
{
for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
*__r = *__first;
- std::__make_heap<_AlgPolicy, _Compare>(__result_first, __r, __comp);
+ std::__make_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
for (; __first != __last; ++__first)
- if (__comp(*__first, *__result_first))
- {
+ if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) {
*__result_first = *__first;
- std::__sift_down<_AlgPolicy, _Compare>(__result_first, __comp, __len, __result_first);
+ std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first);
}
- std::__sort_heap<_AlgPolicy, _Compare>(__result_first, __r, __comp);
+ std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
}
- return __r;
+
+ return pair<_InputIterator, _RandomAccessIterator>(
+ _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r));
}
template <class _InputIterator, class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_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 std::__partial_sort_copy<_ClassicAlgPolicy, _Comp_ref>(
- __first, __last, __result_first, __result_last, __comp);
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
+ "Comparator has to be callable");
+
+ auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,
+ static_cast<__comp_ref_type<_Compare> >(__comp), __identity(), __identity());
+ return __result.second;
}
template <class _InputIterator, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
diff --git a/libcxx/include/__algorithm/partition.h b/libcxx/include/__algorithm/partition.h
index 60b4e290ebeb..0e094bf8dd92 100644
--- a/libcxx/include/__algorithm/partition.h
+++ b/libcxx/include/__algorithm/partition.h
@@ -23,7 +23,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)
{
while (true)
@@ -48,7 +48,7 @@ __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred,
}
template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_BidirectionalIterator, _BidirectionalIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator, _BidirectionalIterator>
__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,
bidirectional_iterator_tag)
{
@@ -76,15 +76,15 @@ __partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicat
}
template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
pair<_ForwardIterator, _ForwardIterator> __partition(
_ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {
- return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>(
+ return std::__partition_impl<__remove_cvref_t<_Predicate>&, _AlgPolicy>(
std::move(__first), std::move(__last), __pred, __iter_category);
}
template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
diff --git a/libcxx/include/__algorithm/partition_copy.h b/libcxx/include/__algorithm/partition_copy.h
index cacde0bfd47b..ff8826a93712 100644
--- a/libcxx/include/__algorithm/partition_copy.h
+++ b/libcxx/include/__algorithm/partition_copy.h
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator1,
class _OutputIterator2, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_OutputIterator1, _OutputIterator2>
partition_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator1 __out_true, _OutputIterator2 __out_false,
_Predicate __pred)
diff --git a/libcxx/include/__algorithm/partition_point.h b/libcxx/include/__algorithm/partition_point.h
index 1675534e60d5..6ede71a264cd 100644
--- a/libcxx/include/__algorithm/partition_point.h
+++ b/libcxx/include/__algorithm/partition_point.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _ForwardIterator, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
diff --git a/libcxx/include/__algorithm/pop_heap.h b/libcxx/include/__algorithm/pop_heap.h
index 870af50c133e..94d32a42391b 100644
--- a/libcxx/include/__algorithm/pop_heap.h
+++ b/libcxx/include/__algorithm/pop_heap.h
@@ -27,18 +27,17 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
_LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");
- using _CompRef = typename __comp_ref_type<_Compare>::type;
- _CompRef __comp_ref = __comp;
+ __comp_ref_type<_Compare> __comp_ref = __comp;
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
if (__len > 1) {
value_type __top = _IterOps<_AlgPolicy>::__iter_move(__first); // create a hole at __first
- _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy, _CompRef>(__first, __comp_ref, __len);
+ _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy>(__first, __comp_ref, __len);
--__last;
if (__hole == __last) {
@@ -47,13 +46,13 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
*__hole = _IterOps<_AlgPolicy>::__iter_move(__last);
++__hole;
*__last = std::move(__top);
- std::__sift_up<_AlgPolicy, _CompRef>(__first, __hole, __comp_ref, __hole - __first);
+ std::__sift_up<_AlgPolicy>(__first, __hole, __comp_ref, __hole - __first);
}
}
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
@@ -63,7 +62,7 @@ void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
std::pop_heap(std::move(__first), std::move(__last),
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/prev_permutation.h b/libcxx/include/__algorithm/prev_permutation.h
index 9dbc1dad0124..0b86ab74ee01 100644
--- a/libcxx/include/__algorithm/prev_permutation.h
+++ b/libcxx/include/__algorithm/prev_permutation.h
@@ -11,10 +11,12 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/reverse.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,44 +24,49 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+pair<_BidirectionalIterator, bool>
+__prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
{
- _BidirectionalIterator __i = __last;
+ using _Result = pair<_BidirectionalIterator, bool>;
+
+ _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ _BidirectionalIterator __i = __last_iter;
if (__first == __last || __first == --__i)
- return false;
+ return _Result(std::move(__last_iter), false);
+
while (true)
{
_BidirectionalIterator __ip1 = __i;
if (__comp(*__ip1, *--__i))
{
- _BidirectionalIterator __j = __last;
+ _BidirectionalIterator __j = __last_iter;
while (!__comp(*--__j, *__i))
;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
+ _IterOps<_AlgPolicy>::iter_swap(__i, __j);
+ std::__reverse<_AlgPolicy>(__ip1, __last_iter);
+ return _Result(std::move(__last_iter), true);
}
if (__i == __first)
{
- _VSTD::reverse(__first, __last);
- return false;
+ std::__reverse<_AlgPolicy>(__first, __last_iter);
+ return _Result(std::move(__last_iter), false);
}
}
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ return std::__prev_permutation<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)).second;
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
diff --git a/libcxx/include/__algorithm/push_heap.h b/libcxx/include/__algorithm/push_heap.h
index 716670b76788..90684957744d 100644
--- a/libcxx/include/__algorithm/push_heap.h
+++ b/libcxx/include/__algorithm/push_heap.h
@@ -24,8 +24,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
@@ -50,15 +50,14 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
}
template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
- using _CompRef = typename __comp_ref_type<_Compare>::type;
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
- std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len);
+ std::__sift_up<_AlgPolicy, __comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp, __len);
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
@@ -67,7 +66,7 @@ void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
std::push_heap(std::move(__first), std::move(__last),
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/ranges_adjacent_find.h b/libcxx/include/__algorithm/ranges_adjacent_find.h
index e798d568299d..d338d13e6eee 100644
--- a/libcxx/include/__algorithm/ranges_adjacent_find.h
+++ b/libcxx/include/__algorithm/ranges_adjacent_find.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -50,7 +50,7 @@ struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
class _Proj = identity,
indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
}
@@ -59,7 +59,7 @@ struct __fn {
class _Proj = identity,
indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,
projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -73,6 +73,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
diff --git a/libcxx/include/__algorithm/ranges_all_of.h b/libcxx/include/__algorithm/ranges_all_of.h
index a146865652a7..e45c4e584379 100644
--- a/libcxx/include/__algorithm/ranges_all_of.h
+++ b/libcxx/include/__algorithm/ranges_all_of.h
@@ -22,7 +22,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,14 +42,14 @@ struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
}
template <input_range _Range, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -63,6 +63,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
diff --git a/libcxx/include/__algorithm/ranges_any_of.h b/libcxx/include/__algorithm/ranges_any_of.h
index 11c52cbe21ea..e7d1e723a70f 100644
--- a/libcxx/include/__algorithm/ranges_any_of.h
+++ b/libcxx/include/__algorithm/ranges_any_of.h
@@ -22,7 +22,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,14 +42,14 @@ struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
}
template <input_range _Range, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -63,6 +63,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
diff --git a/libcxx/include/__algorithm/ranges_binary_search.h b/libcxx/include/__algorithm/ranges_binary_search.h
index 6da68834aa3b..b2a8977652fb 100644
--- a/libcxx/include/__algorithm/ranges_binary_search.h
+++ b/libcxx/include/__algorithm/ranges_binary_search.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -33,7 +33,7 @@ namespace __binary_search {
struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
@@ -41,7 +41,7 @@ struct __fn {
template <forward_range _Range, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);
@@ -58,6 +58,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
diff --git a/libcxx/include/__algorithm/ranges_clamp.h b/libcxx/include/__algorithm/ranges_clamp.h
new file mode 100644
index 000000000000..09a97fc790ea
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_clamp.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CLAMP_H
+#define _LIBCPP___ALGORITHM_RANGES_CLAMP_H
+
+#include <__assert>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __clamp {
+struct __fn {
+
+ template <class _Type,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
+ const _Type& operator()(const _Type& __value,
+ const _Type& __low,
+ const _Type& __high,
+ _Comp __comp = {},
+ _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(!bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))),
+ "Bad bounds passed to std::ranges::clamp");
+
+ if (std::invoke(__comp, std::invoke(__proj, __value), std::invoke(__proj, __low)))
+ return __low;
+ else if (std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __value)))
+ return __high;
+ else
+ return __value;
+ }
+
+};
+} // namespace __clamp
+
+inline namespace __cpo {
+ inline constexpr auto clamp = __clamp::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H
diff --git a/libcxx/include/__algorithm/ranges_copy.h b/libcxx/include/__algorithm/ranges_copy.h
index f5d6d5cd139a..bb02c84efbdb 100644
--- a/libcxx/include/__algorithm/ranges_copy.h
+++ b/libcxx/include/__algorithm/ranges_copy.h
@@ -11,6 +11,7 @@
#include <__algorithm/copy.h>
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__functional/identity.h>
#include <__iterator/concepts.h>
@@ -18,12 +19,13 @@
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -39,7 +41,7 @@ struct __fn {
requires indirectly_copyable<_InIter, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr
copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
- auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
+ auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
return {std::move(__ret.first), std::move(__ret.second)};
}
@@ -47,7 +49,7 @@ struct __fn {
requires indirectly_copyable<iterator_t<_Range>, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr
copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {
- auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
+ auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
return {std::move(__ret.first), std::move(__ret.second)};
}
};
@@ -60,6 +62,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_copy_backward.h b/libcxx/include/__algorithm/ranges_copy_backward.h
index 673df8025fab..f41af66f39fb 100644
--- a/libcxx/include/__algorithm/ranges_copy_backward.h
+++ b/libcxx/include/__algorithm/ranges_copy_backward.h
@@ -14,7 +14,6 @@
#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/concepts.h>
-#include <__iterator/reverse_iterator.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
@@ -24,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -61,6 +60,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
diff --git a/libcxx/include/__algorithm/ranges_copy_if.h b/libcxx/include/__algorithm/ranges_copy_if.h
index 492104fbbfba..dba41c3b3ab9 100644
--- a/libcxx/include/__algorithm/ranges_copy_if.h
+++ b/libcxx/include/__algorithm/ranges_copy_if.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -76,6 +76,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
diff --git a/libcxx/include/__algorithm/ranges_copy_n.h b/libcxx/include/__algorithm/ranges_copy_n.h
index eaa05c954686..04bb80b3ba1a 100644
--- a/libcxx/include/__algorithm/ranges_copy_n.h
+++ b/libcxx/include/__algorithm/ranges_copy_n.h
@@ -11,6 +11,7 @@
#include <__algorithm/copy.h>
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/ranges_copy.h>
#include <__config>
#include <__functional/identity.h>
@@ -26,7 +27,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -51,7 +52,7 @@ struct __fn {
template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr static
copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
- auto __ret = std::__copy(__first, __first + __n, __result);
+ auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result);
return {__ret.first, __ret.second};
}
@@ -69,7 +70,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/ranges_count.h b/libcxx/include/__algorithm/ranges_count.h
index 670df26911d0..527dd0620085 100644
--- a/libcxx/include/__algorithm/ranges_count.h
+++ b/libcxx/include/__algorithm/ranges_count.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -34,7 +34,7 @@ namespace __count {
struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __e) { return __e == __value; };
return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
@@ -42,7 +42,7 @@ struct __fn {
template <input_range _Range, class _Type, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __e) { return __e == __value; };
return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
@@ -57,6 +57,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H
diff --git a/libcxx/include/__algorithm/ranges_count_if.h b/libcxx/include/__algorithm/ranges_count_if.h
index 0f34ee9f2b1b..931618b7b545 100644
--- a/libcxx/include/__algorithm/ranges_count_if.h
+++ b/libcxx/include/__algorithm/ranges_count_if.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -46,14 +46,14 @@ namespace __count_if {
struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
}
template <input_range _Range, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
}
@@ -67,6 +67,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
diff --git a/libcxx/include/__algorithm/ranges_equal.h b/libcxx/include/__algorithm/ranges_equal.h
index c5f2d2332216..3c417f09de90 100644
--- a/libcxx/include/__algorithm/ranges_equal.h
+++ b/libcxx/include/__algorithm/ranges_equal.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -60,7 +60,7 @@ public:
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred __pred = {},
@@ -83,7 +83,7 @@ public:
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range1&& __range1,
_Range2&& __range2,
_Pred __pred = {},
@@ -110,6 +110,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H
diff --git a/libcxx/include/__algorithm/ranges_equal_range.h b/libcxx/include/__algorithm/ranges_equal_range.h
index dd4b377df1a1..94dc058e7bc1 100644
--- a/libcxx/include/__algorithm/ranges_equal_range.h
+++ b/libcxx/include/__algorithm/ranges_equal_range.h
@@ -24,12 +24,13 @@
#include <__ranges/subrange.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,7 +44,7 @@ struct __fn {
class _Tp,
class _Proj = identity,
indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
auto __ret = std::__equal_range<_RangeAlgPolicy>(
std::move(__first), std::move(__last), __value, __comp, __proj);
@@ -55,7 +56,7 @@ struct __fn {
class _Tp,
class _Proj = identity,
indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
auto __ret = std::__equal_range<_RangeAlgPolicy>(
ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
@@ -72,6 +73,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
diff --git a/libcxx/include/__algorithm/ranges_fill.h b/libcxx/include/__algorithm/ranges_fill.h
index 7ce4a76ba9e9..6ebc2bd67d6b 100644
--- a/libcxx/include/__algorithm/ranges_fill.h
+++ b/libcxx/include/__algorithm/ranges_fill.h
@@ -20,7 +20,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -54,6 +54,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H
diff --git a/libcxx/include/__algorithm/ranges_fill_n.h b/libcxx/include/__algorithm/ranges_fill_n.h
index d93c573406ec..a2660e8b592a 100644
--- a/libcxx/include/__algorithm/ranges_fill_n.h
+++ b/libcxx/include/__algorithm/ranges_fill_n.h
@@ -17,7 +17,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,6 +43,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H
diff --git a/libcxx/include/__algorithm/ranges_find.h b/libcxx/include/__algorithm/ranges_find.h
index ca6d2f438295..580c2a14c9ed 100644
--- a/libcxx/include/__algorithm/ranges_find.h
+++ b/libcxx/include/__algorithm/ranges_find.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -35,7 +35,7 @@ namespace __find {
struct __fn {
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
@@ -43,7 +43,7 @@ struct __fn {
template <input_range _Rp, class _Tp, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
@@ -58,6 +58,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H
diff --git a/libcxx/include/__algorithm/ranges_find_end.h b/libcxx/include/__algorithm/ranges_find_end.h
index 270b00649848..ea36f4d4e6e7 100644
--- a/libcxx/include/__algorithm/ranges_find_end.h
+++ b/libcxx/include/__algorithm/ranges_find_end.h
@@ -21,12 +21,13 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/subrange.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -39,7 +40,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred __pred = {},
@@ -64,7 +65,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
_Range2&& __range2,
_Pred __pred = {},
@@ -92,6 +93,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H
diff --git a/libcxx/include/__algorithm/ranges_find_first_of.h b/libcxx/include/__algorithm/ranges_find_first_of.h
index ae31d38e6a95..9d66e7511c0f 100644
--- a/libcxx/include/__algorithm/ranges_find_first_of.h
+++ b/libcxx/include/__algorithm/ranges_find_first_of.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -54,7 +54,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter1 operator()(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred __pred = {},
@@ -73,7 +73,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,
_Range2&& __range2,
_Pred __pred = {},
@@ -96,6 +96,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
diff --git a/libcxx/include/__algorithm/ranges_find_if.h b/libcxx/include/__algorithm/ranges_find_if.h
index 65ac122f6677..45ce6e460d68 100644
--- a/libcxx/include/__algorithm/ranges_find_if.h
+++ b/libcxx/include/__algorithm/ranges_find_if.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,14 +45,14 @@ struct __fn {
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
}
template <input_range _Rp, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
}
@@ -66,6 +66,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
diff --git a/libcxx/include/__algorithm/ranges_find_if_not.h b/libcxx/include/__algorithm/ranges_find_if_not.h
index 9a1adf71fc58..3dd12132754b 100644
--- a/libcxx/include/__algorithm/ranges_find_if_not.h
+++ b/libcxx/include/__algorithm/ranges_find_if_not.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -35,7 +35,7 @@ namespace __find_if_not {
struct __fn {
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
@@ -43,7 +43,7 @@ struct __fn {
template <input_range _Rp, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
@@ -58,6 +58,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
diff --git a/libcxx/include/__algorithm/ranges_for_each.h b/libcxx/include/__algorithm/ranges_for_each.h
index f284c0ee3ad4..0c70c05981a7 100644
--- a/libcxx/include/__algorithm/ranges_for_each.h
+++ b/libcxx/include/__algorithm/ranges_for_each.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -73,6 +73,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
diff --git a/libcxx/include/__algorithm/ranges_for_each_n.h b/libcxx/include/__algorithm/ranges_for_each_n.h
index 013afbd19389..261816aba436 100644
--- a/libcxx/include/__algorithm/ranges_for_each_n.h
+++ b/libcxx/include/__algorithm/ranges_for_each_n.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -61,6 +61,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
diff --git a/libcxx/include/__algorithm/ranges_generate.h b/libcxx/include/__algorithm/ranges_generate.h
index 149296574d80..ae486ae65395 100644
--- a/libcxx/include/__algorithm/ranges_generate.h
+++ b/libcxx/include/__algorithm/ranges_generate.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -68,6 +68,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
diff --git a/libcxx/include/__algorithm/ranges_generate_n.h b/libcxx/include/__algorithm/ranges_generate_n.h
index 63f466cecdd7..e625e3a97428 100644
--- a/libcxx/include/__algorithm/ranges_generate_n.h
+++ b/libcxx/include/__algorithm/ranges_generate_n.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -57,6 +57,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
diff --git a/libcxx/include/__algorithm/ranges_includes.h b/libcxx/include/__algorithm/ranges_includes.h
index 2c7581af68af..8438117cfa80 100644
--- a/libcxx/include/__algorithm/ranges_includes.h
+++ b/libcxx/include/__algorithm/ranges_includes.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,7 +43,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity,
indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
_Iter1 __first1,
_Sent1 __last1,
_Iter2 __first2,
@@ -68,7 +68,7 @@ struct __fn {
class _Proj2 = identity,
indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
_Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
return std::__includes(
ranges::begin(__range1),
@@ -90,6 +90,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
diff --git a/libcxx/include/__algorithm/ranges_inplace_merge.h b/libcxx/include/__algorithm/ranges_inplace_merge.h
index a0867e486c3a..88171a65c8e9 100644
--- a/libcxx/include/__algorithm/ranges_inplace_merge.h
+++ b/libcxx/include/__algorithm/ranges_inplace_merge.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
#include <__algorithm/inplace_merge.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__config>
#include <__functional/identity.h>
@@ -17,6 +18,7 @@
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
#include <__iterator/projected.h>
#include <__iterator/sortable.h>
#include <__ranges/access.h>
@@ -29,35 +31,45 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __inplace_merge {
-struct __fn {
+ struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
+ auto __last_iter = ranges::next(__middle, __last);
+ std::__inplace_merge<_RangeAlgPolicy>(
+ std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));
+ return __last_iter;
+ }
- template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
- requires sortable<_Iter, _Comp, _Proj>
- _LIBCPP_HIDE_FROM_ABI
- _Iter operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__middle; (void)__last; (void)__comp; (void)__proj;
- return {};
- }
+ template <
+ bidirectional_iterator _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less,
+ class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI _Iter
+ operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
+ }
- template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
- requires sortable<iterator_t<_Range>, _Comp, _Proj>
- _LIBCPP_HIDE_FROM_ABI
- borrowed_iterator_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle,
- _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__middle; (void)__comp; (void)__proj;
- return {};
- }
-
-};
+ template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<
+ iterator_t<_Range>,
+ _Comp,
+ _Proj> _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>
+ operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
+ }
+ };
} // namespace __inplace_merge
@@ -68,6 +80,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
diff --git a/libcxx/include/__algorithm/ranges_is_heap.h b/libcxx/include/__algorithm/ranges_is_heap.h
index a3e86d1a8d72..a16c075b0763 100644
--- a/libcxx/include/__algorithm/ranges_is_heap.h
+++ b/libcxx/include/__algorithm/ranges_is_heap.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -39,7 +39,7 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr
static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
return __result == __last;
@@ -47,14 +47,14 @@ struct __fn {
template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
}
template <random_access_range _Range, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
}
@@ -69,6 +69,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
diff --git a/libcxx/include/__algorithm/ranges_is_heap_until.h b/libcxx/include/__algorithm/ranges_is_heap_until.h
index bcd33ad404e8..8c8dac5bc909 100644
--- a/libcxx/include/__algorithm/ranges_is_heap_until.h
+++ b/libcxx/include/__algorithm/ranges_is_heap_until.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -40,21 +40,21 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr
static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
}
template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
}
template <random_access_range _Range, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
}
@@ -70,6 +70,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
diff --git a/libcxx/include/__algorithm/ranges_is_partitioned.h b/libcxx/include/__algorithm/ranges_is_partitioned.h
index 3d572895ebe1..b903953d6165 100644
--- a/libcxx/include/__algorithm/ranges_is_partitioned.h
+++ b/libcxx/include/__algorithm/ranges_is_partitioned.h
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -54,7 +54,7 @@ struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);
}
@@ -62,7 +62,7 @@ struct __fn {
template <input_range _Range,
class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -76,6 +76,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
diff --git a/libcxx/include/__algorithm/ranges_is_permutation.h b/libcxx/include/__algorithm/ranges_is_permutation.h
new file mode 100644
index 000000000000..b617500ea0d8
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_is_permutation.h
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_IS_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
+
+#include <__algorithm/is_permutation.h>
+#include <__algorithm/iterator_operations.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_permutation {
+struct __fn {
+
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __is_permutation_func_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
+ return std::__is_permutation<_RangeAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
+ }
+
+ template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_equivalence_relation<projected<_Iter1, _Proj1>,
+ projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return __is_permutation_func_impl(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
+ }
+
+ template <forward_range _Range1,
+ forward_range _Range2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range1&& __range1, _Range2&& __range2,
+ _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
+ if (ranges::distance(__range1) != ranges::distance(__range2))
+ return false;
+ }
+
+ return __is_permutation_func_impl(
+ ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2),
+ __pred, __proj1, __proj2);
+ }
+};
+} // namespace __is_permutation
+
+inline namespace __cpo {
+ inline constexpr auto is_permutation = __is_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
diff --git a/libcxx/include/__algorithm/ranges_is_sorted.h b/libcxx/include/__algorithm/ranges_is_sorted.h
index 938e69afba8d..ce3032ff226e 100644
--- a/libcxx/include/__algorithm/ranges_is_sorted.h
+++ b/libcxx/include/__algorithm/ranges_is_sorted.h
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -33,7 +33,7 @@ struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
class _Proj = identity,
indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
}
@@ -41,7 +41,7 @@ struct __fn {
template <forward_range _Range,
class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
auto __last = ranges::end(__range);
return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
@@ -56,6 +56,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
diff --git a/libcxx/include/__algorithm/ranges_is_sorted_until.h b/libcxx/include/__algorithm/ranges_is_sorted_until.h
index c8f0608e1255..17fc42e97fd3 100644
--- a/libcxx/include/__algorithm/ranges_is_sorted_until.h
+++ b/libcxx/include/__algorithm/ranges_is_sorted_until.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -49,7 +49,7 @@ struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
class _Proj = identity,
indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
}
@@ -57,7 +57,7 @@ struct __fn {
template <forward_range _Range,
class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
}
@@ -71,6 +71,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
diff --git a/libcxx/include/__algorithm/ranges_iterator_concept.h b/libcxx/include/__algorithm/ranges_iterator_concept.h
index 3323119317ae..3ac6b317031a 100644
--- a/libcxx/include/__algorithm/ranges_iterator_concept.h
+++ b/libcxx/include/__algorithm/ranges_iterator_concept.h
@@ -12,13 +12,13 @@
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -26,7 +26,7 @@ namespace ranges {
template <class _IterMaybeQualified>
consteval auto __get_iterator_concept() {
- using _Iter = __uncvref_t<_IterMaybeQualified>;
+ using _Iter = __remove_cvref_t<_IterMaybeQualified>;
if constexpr (contiguous_iterator<_Iter>)
return contiguous_iterator_tag();
@@ -46,6 +46,6 @@ using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
} // namespace ranges
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
diff --git a/libcxx/include/__algorithm/ranges_lexicographical_compare.h b/libcxx/include/__algorithm/ranges_lexicographical_compare.h
index fe709f7a7f70..2972e327169d 100644
--- a/libcxx/include/__algorithm/ranges_lexicographical_compare.h
+++ b/libcxx/include/__algorithm/ranges_lexicographical_compare.h
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -55,7 +55,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity,
indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Comp __comp = {},
@@ -74,7 +74,7 @@ struct __fn {
class _Proj2 = identity,
indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),
ranges::begin(__range2), ranges::end(__range2),
@@ -93,6 +93,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
diff --git a/libcxx/include/__algorithm/ranges_lower_bound.h b/libcxx/include/__algorithm/ranges_lower_bound.h
index 1a9ae204a1ee..78cbb6d4fb24 100644
--- a/libcxx/include/__algorithm/ranges_lower_bound.h
+++ b/libcxx/include/__algorithm/ranges_lower_bound.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -37,14 +37,14 @@ namespace __lower_bound {
struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
}
template <forward_range _Range, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __r,
const _Type& __value,
_Comp __comp = {},
@@ -61,6 +61,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
diff --git a/libcxx/include/__algorithm/ranges_make_heap.h b/libcxx/include/__algorithm/ranges_make_heap.h
index 8eabdd12cd2f..f25c7ab58888 100644
--- a/libcxx/include/__algorithm/ranges_make_heap.h
+++ b/libcxx/include/__algorithm/ranges_make_heap.h
@@ -32,7 +32,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,7 +45,7 @@ struct __fn {
_Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__make_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
@@ -75,6 +75,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
diff --git a/libcxx/include/__algorithm/ranges_max.h b/libcxx/include/__algorithm/ranges_max.h
index f48bc3ececa2..55aef997698c 100644
--- a/libcxx/include/__algorithm/ranges_max.h
+++ b/libcxx/include/__algorithm/ranges_max.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -39,14 +39,14 @@ namespace __max {
struct __fn {
template <class _Tp, class _Proj = identity,
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;
}
template <copyable _Tp, class _Proj = identity,
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
@@ -57,7 +57,7 @@ struct __fn {
template <input_range _Rp, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);
@@ -88,6 +88,6 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 &&
#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
diff --git a/libcxx/include/__algorithm/ranges_max_element.h b/libcxx/include/__algorithm/ranges_max_element.h
index d8d7242e176b..490f32075a4c 100644
--- a/libcxx/include/__algorithm/ranges_max_element.h
+++ b/libcxx/include/__algorithm/ranges_max_element.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -33,7 +33,7 @@ namespace __max_element {
struct __fn {
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
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
@@ -41,7 +41,7 @@ struct __fn {
template <forward_range _Rp, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
@@ -56,6 +56,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
diff --git a/libcxx/include/__algorithm/ranges_merge.h b/libcxx/include/__algorithm/ranges_merge.h
index c73e09e94ccc..b36a05abc41e 100644
--- a/libcxx/include/__algorithm/ranges_merge.h
+++ b/libcxx/include/__algorithm/ranges_merge.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -47,7 +47,7 @@ template <
class _Comp,
class _Proj1,
class _Proj2>
-_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>>
+_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>, __remove_cvref_t<_InIter2>, __remove_cvref_t<_OutIter>>
__merge_impl(
_InIter1&& __first1,
_Sent1&& __last1,
@@ -107,7 +107,7 @@ struct __fn {
_OutIter,
_Comp,
_Proj1,
- _Proj2>
+ _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
operator()(
_Range1&& __range1,
@@ -137,6 +137,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H
diff --git a/libcxx/include/__algorithm/ranges_min.h b/libcxx/include/__algorithm/ranges_min.h
index 0bb1e72ac5ac..0e31f57fb8dd 100644
--- a/libcxx/include/__algorithm/ranges_min.h
+++ b/libcxx/include/__algorithm/ranges_min.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -38,14 +38,14 @@ namespace __min {
struct __fn {
template <class _Tp, class _Proj = identity,
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;
}
template <copyable _Tp, class _Proj = identity,
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
@@ -54,7 +54,7 @@ struct __fn {
template <input_range _Rp, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);
@@ -84,6 +84,6 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17 &&
#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
diff --git a/libcxx/include/__algorithm/ranges_min_element.h b/libcxx/include/__algorithm/ranges_min_element.h
index 26f95fe3a6d2..1751874d03bb 100644
--- a/libcxx/include/__algorithm/ranges_min_element.h
+++ b/libcxx/include/__algorithm/ranges_min_element.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -48,14 +48,14 @@ namespace __min_element {
struct __fn {
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
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
return ranges::__min_element_impl(__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
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
}
@@ -69,6 +69,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h
index 2f4bba0e7cc0..f82e00551e47 100644
--- a/libcxx/include/__algorithm/ranges_minmax.h
+++ b/libcxx/include/__algorithm/ranges_minmax.h
@@ -23,13 +23,14 @@
#include <__ranges/concepts.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -44,7 +45,7 @@ namespace __minmax {
struct __fn {
template <class _Type, class _Proj = identity,
indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
return {__b, __a};
@@ -53,7 +54,7 @@ struct __fn {
template <copyable _Type, class _Proj = identity,
indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
@@ -63,7 +64,7 @@ struct __fn {
template <input_range _Range, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);
@@ -128,6 +129,6 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
diff --git a/libcxx/include/__algorithm/ranges_minmax_element.h b/libcxx/include/__algorithm/ranges_minmax_element.h
index b7bb26cefe95..6699f9626e1b 100644
--- a/libcxx/include/__algorithm/ranges_minmax_element.h
+++ b/libcxx/include/__algorithm/ranges_minmax_element.h
@@ -29,7 +29,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,7 +42,7 @@ namespace __minmax_element {
struct __fn {
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
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
return {__ret.first, __ret.second};
@@ -50,7 +50,7 @@ struct __fn {
template <forward_range _Rp, class _Proj = identity,
indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
@@ -67,6 +67,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
diff --git a/libcxx/include/__algorithm/ranges_mismatch.h b/libcxx/include/__algorithm/ranges_mismatch.h
index 4c1440b5da06..4fd051792838 100644
--- a/libcxx/include/__algorithm/ranges_mismatch.h
+++ b/libcxx/include/__algorithm/ranges_mismatch.h
@@ -27,7 +27,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -55,7 +55,7 @@ struct __fn {
input_iterator _I2, sentinel_for<_I2> _S2,
class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
_Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
@@ -64,7 +64,7 @@ struct __fn {
template <input_range _R1, input_range _R2,
class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),
@@ -78,7 +78,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/ranges_move.h b/libcxx/include/__algorithm/ranges_move.h
index ad4342d7c989..46a0970f834a 100644
--- a/libcxx/include/__algorithm/ranges_move.h
+++ b/libcxx/include/__algorithm/ranges_move.h
@@ -10,10 +10,10 @@
#define _LIBCPP___ALGORITHM_RANGES_MOVE_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/move.h>
#include <__config>
#include <__iterator/concepts.h>
-#include <__iterator/iter_move.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -36,24 +36,12 @@ namespace __move {
struct __fn {
template <class _InIter, class _Sent, class _OutIter>
- requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value
_LIBCPP_HIDE_FROM_ABI constexpr static
move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result));
+ auto __ret = std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
return {std::move(__ret.first), std::move(__ret.second)};
}
- template <class _InIter, class _Sent, class _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr static
- move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
- while (__first != __last) {
- *__result = ranges::iter_move(__first);
- ++__first;
- ++__result;
- }
- return {std::move(__first), std::move(__result)};
- }
-
template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
requires indirectly_movable<_InIter, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr
@@ -78,6 +66,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
diff --git a/libcxx/include/__algorithm/ranges_move_backward.h b/libcxx/include/__algorithm/ranges_move_backward.h
index b3dfa7139603..d4e8eb1a5008 100644
--- a/libcxx/include/__algorithm/ranges_move_backward.h
+++ b/libcxx/include/__algorithm/ranges_move_backward.h
@@ -10,12 +10,12 @@
#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/ranges_move.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/move_backward.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iter_move.h>
#include <__iterator/next.h>
-#include <__iterator/reverse_iterator.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -40,10 +40,8 @@ struct __fn {
template <class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr static
move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)),
- std::make_reverse_iterator(__first),
- std::make_reverse_iterator(__result));
- return {std::move(__ret.in.base()), std::move(__ret.out.base())};
+ auto __ret = std::__move_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
}
template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
@@ -70,6 +68,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
diff --git a/libcxx/include/__algorithm/ranges_next_permutation.h b/libcxx/include/__algorithm/ranges_next_permutation.h
new file mode 100644
index 000000000000..6c8e8e1529f2
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_next_permutation.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___ALGORITHM_RANGES_NEXT_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
+
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/next_permutation.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter>
+using next_permutation_result = in_found_result<_InIter>;
+
+namespace __next_permutation {
+
+struct __fn {
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__next_permutation<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<borrowed_iterator_t<_Range>>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__next_permutation<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+};
+
+} // namespace __next_permutation
+
+inline namespace __cpo {
+constexpr inline auto next_permutation = __next_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
diff --git a/libcxx/include/__algorithm/ranges_none_of.h b/libcxx/include/__algorithm/ranges_none_of.h
index 706ff5cd741d..b39e570fd33a 100644
--- a/libcxx/include/__algorithm/ranges_none_of.h
+++ b/libcxx/include/__algorithm/ranges_none_of.h
@@ -22,7 +22,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,14 +42,14 @@ struct __fn {
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
}
template <input_range _Range, class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -63,6 +63,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
diff --git a/libcxx/include/__algorithm/ranges_nth_element.h b/libcxx/include/__algorithm/ranges_nth_element.h
index b15eb816b918..d9ec4f13825b 100644
--- a/libcxx/include/__algorithm/ranges_nth_element.h
+++ b/libcxx/include/__algorithm/ranges_nth_element.h
@@ -31,7 +31,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -44,7 +44,7 @@ struct __fn {
_Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp);
return __last_iter;
@@ -75,6 +75,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
diff --git a/libcxx/include/__algorithm/ranges_partial_sort.h b/libcxx/include/__algorithm/ranges_partial_sort.h
index 5e82bc6fcc32..3ea0a7fb44b5 100644
--- a/libcxx/include/__algorithm/ranges_partial_sort.h
+++ b/libcxx/include/__algorithm/ranges_partial_sort.h
@@ -27,12 +27,13 @@
#include <__ranges/dangling.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,7 +44,7 @@ struct __fn {
template <class _Iter, class _Sent, class _Comp, class _Proj>
_LIBCPP_HIDE_FROM_ABI constexpr static
_Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
}
@@ -72,6 +73,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
diff --git a/libcxx/include/__algorithm/ranges_partial_sort_copy.h b/libcxx/include/__algorithm/ranges_partial_sort_copy.h
index 55ad2ca4e686..212db555a8d3 100644
--- a/libcxx/include/__algorithm/ranges_partial_sort_copy.h
+++ b/libcxx/include/__algorithm/ranges_partial_sort_copy.h
@@ -10,11 +10,11 @@
#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/partial_sort_copy.h>
#include <__config>
#include <__functional/identity.h>
-#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
@@ -23,14 +23,14 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -52,9 +52,11 @@ struct __fn {
partial_sort_copy_result<_Iter1, _Iter2>
operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result_first, _Sent2 __result_last,
_Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result_first; (void)__result_last; (void)__comp; (void)__proj1; (void)__proj2;
- return {};
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result_first), std::move(__result_last),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
}
template <input_range _Range1, random_access_range _Range2, class _Comp = ranges::less,
@@ -67,9 +69,11 @@ struct __fn {
partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>>
operator()(_Range1&& __range, _Range2&& __result_range, _Comp __comp = {},
_Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
- // TODO: implement
- (void)__range; (void)__result_range; (void)__comp; (void)__proj1; (void)__proj2;
- return {};
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), ranges::begin(__result_range), ranges::end(__result_range),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
}
};
@@ -83,6 +87,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_partition.h b/libcxx/include/__algorithm/ranges_partition.h
index 60bee699d90e..8b3aae5c250d 100644
--- a/libcxx/include/__algorithm/ranges_partition.h
+++ b/libcxx/include/__algorithm/ranges_partition.h
@@ -26,13 +26,14 @@
#include <__ranges/subrange.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#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_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,8 +44,8 @@ struct __fn {
template <class _Iter, class _Sent, class _Proj, class _Pred>
_LIBCPP_HIDE_FROM_ABI static constexpr
- subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
- auto&& __projected_pred = ranges::__make_projected_pred(__pred, __proj);
+ subrange<__remove_cvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
auto __result = std::__partition<_RangeAlgPolicy>(
std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
@@ -77,6 +78,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H
diff --git a/libcxx/include/__algorithm/ranges_partition_copy.h b/libcxx/include/__algorithm/ranges_partition_copy.h
index 7201a8cbfe45..e7a9a347df5a 100644
--- a/libcxx/include/__algorithm/ranges_partition_copy.h
+++ b/libcxx/include/__algorithm/ranges_partition_copy.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,7 +43,7 @@ struct __fn {
template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
_LIBCPP_HIDE_FROM_ABI constexpr
static partition_copy_result<
- __uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2>
+ __remove_cvref_t<_InIter>, __remove_cvref_t<_OutIter1>, __remove_cvref_t<_OutIter2>
> __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
_Pred& __pred, _Proj& __proj) {
for (; __first != __last; ++__first) {
@@ -93,6 +93,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_partition_point.h b/libcxx/include/__algorithm/ranges_partition_point.h
index 6614a0bb50fd..2bd118d4def0 100644
--- a/libcxx/include/__algorithm/ranges_partition_point.h
+++ b/libcxx/include/__algorithm/ranges_partition_point.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -83,6 +83,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
diff --git a/libcxx/include/__algorithm/ranges_pop_heap.h b/libcxx/include/__algorithm/ranges_pop_heap.h
index 92df6119d34a..65beec886441 100644
--- a/libcxx/include/__algorithm/ranges_pop_heap.h
+++ b/libcxx/include/__algorithm/ranges_pop_heap.h
@@ -32,7 +32,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -46,7 +46,7 @@ struct __fn {
auto __last_iter = ranges::next(__first, __last);
auto __len = __last_iter - __first;
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__pop_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp, __len);
return __last_iter;
@@ -76,6 +76,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
diff --git a/libcxx/include/__algorithm/ranges_prev_permutation.h b/libcxx/include/__algorithm/ranges_prev_permutation.h
new file mode 100644
index 000000000000..6866d90cf484
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_prev_permutation.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
+
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/prev_permutation.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter>
+using prev_permutation_result = in_found_result<_InIter>;
+
+namespace __prev_permutation {
+
+struct __fn {
+
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <bidirectional_range _Range,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<borrowed_iterator_t<_Range>>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+};
+
+} // namespace __prev_permutation
+
+inline namespace __cpo {
+constexpr inline auto prev_permutation = __prev_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
diff --git a/libcxx/include/__algorithm/ranges_push_heap.h b/libcxx/include/__algorithm/ranges_push_heap.h
index 4c41b00128de..a1f434741762 100644
--- a/libcxx/include/__algorithm/ranges_push_heap.h
+++ b/libcxx/include/__algorithm/ranges_push_heap.h
@@ -32,7 +32,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,7 +45,7 @@ struct __fn {
_Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
@@ -75,6 +75,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
diff --git a/libcxx/include/__algorithm/ranges_remove.h b/libcxx/include/__algorithm/ranges_remove.h
index a6a1200763d2..dd5c5fb4536a 100644
--- a/libcxx/include/__algorithm/ranges_remove.h
+++ b/libcxx/include/__algorithm/ranges_remove.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -35,7 +35,7 @@ struct __fn {
template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __other) { return __value == __other; };
return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
@@ -44,7 +44,7 @@ struct __fn {
template <forward_range _Range, class _Type, class _Proj = identity>
requires permutable<iterator_t<_Range>>
&& indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
auto __pred = [&](auto&& __other) { return __value == __other; };
return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
@@ -59,6 +59,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H
diff --git a/libcxx/include/__algorithm/ranges_remove_copy.h b/libcxx/include/__algorithm/ranges_remove_copy.h
index 16e9009e7ef0..210222866759 100644
--- a/libcxx/include/__algorithm/ranges_remove_copy.h
+++ b/libcxx/include/__algorithm/ranges_remove_copy.h
@@ -10,26 +10,23 @@
#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/remove_copy.h>
+#include <__algorithm/ranges_remove_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -40,32 +37,30 @@ using remove_copy_result = in_out_result<_InIter, _OutIter>;
namespace __remove_copy {
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type,
- class _Proj = identity>
- requires indirectly_copyable<_InIter, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj;
- return {};
- }
-
- template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__value; (void)__proj;
- return {};
- }
-
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Type,
+ class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __val) { return __value == __val; };
+ return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __val) { return __value == __val; };
+ return ranges::__remove_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
+ }
+ };
} // namespace __remove_copy
@@ -76,6 +71,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_remove_copy_if.h b/libcxx/include/__algorithm/ranges_remove_copy_if.h
index 4eafe425b8e3..4fc67454b926 100644
--- a/libcxx/include/__algorithm/ranges_remove_copy_if.h
+++ b/libcxx/include/__algorithm/ranges_remove_copy_if.h
@@ -29,7 +29,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,33 +38,43 @@ namespace ranges {
template <class _InIter, class _OutIter>
using remove_copy_if_result = in_out_result<_InIter, _OutIter>;
-namespace __remove_copy_if {
-
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter,
- class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
- requires indirectly_copyable<_InIter, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_if_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj;
- return {};
+template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
+_LIBCPP_HIDE_FROM_ABI constexpr in_out_result<_InIter, _OutIter>
+__remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (!std::invoke(__pred, std::invoke(__proj, *__first))) {
+ *__result = *__first;
+ ++__result;
+ }
}
+ return {std::move(__first), std::move(__result)};
+}
- template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
- indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__pred; (void)__proj;
- return {};
- }
+namespace __remove_copy_if {
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
+ }
+ };
} // namespace __remove_copy_if
@@ -75,6 +85,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
diff --git a/libcxx/include/__algorithm/ranges_remove_if.h b/libcxx/include/__algorithm/ranges_remove_if.h
index d4e382e551c6..1f17467fc43e 100644
--- a/libcxx/include/__algorithm/ranges_remove_if.h
+++ b/libcxx/include/__algorithm/ranges_remove_if.h
@@ -27,7 +27,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -56,7 +56,7 @@ struct __fn {
template <permutable _Iter, sentinel_for<_Iter> _Sent,
class _Proj = identity,
indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
}
@@ -65,7 +65,7 @@ struct __fn {
class _Proj = identity,
indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
requires permutable<iterator_t<_Range>>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
@@ -80,6 +80,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
diff --git a/libcxx/include/__algorithm/ranges_replace.h b/libcxx/include/__algorithm/ranges_replace.h
index 5e74c3ff80cb..8b12beacb715 100644
--- a/libcxx/include/__algorithm/ranges_replace.h
+++ b/libcxx/include/__algorithm/ranges_replace.h
@@ -24,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -69,6 +69,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H
diff --git a/libcxx/include/__algorithm/ranges_replace_copy.h b/libcxx/include/__algorithm/ranges_replace_copy.h
index 19ef635d6f15..f87a236fbd0d 100644
--- a/libcxx/include/__algorithm/ranges_replace_copy.h
+++ b/libcxx/include/__algorithm/ranges_replace_copy.h
@@ -10,26 +10,23 @@
#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/replace_copy.h>
+#include <__algorithm/ranges_replace_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -40,35 +37,45 @@ using replace_copy_result = in_out_result<_InIter, _OutIter>;
namespace __replace_copy {
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2,
- output_iterator<const _Type2&> _OutIter, class _Proj = identity>
- requires indirectly_copyable<_InIter, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ class _OldType,
+ class _NewType,
+ output_iterator<const _NewType&> _OutIter,
+ class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _OldType*>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first,
+ _Sent __last,
+ _OutIter __result,
+ const _OldType& __old_value,
+ const _NewType& __new_value,
_Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
- return {};
- }
-
- template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter,
- class _Proj = identity>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ return ranges::__replace_copy_if_impl(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _OldType,
+ class _NewType,
+ output_iterator<const _NewType&> _OutIter,
+ class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _OldType*>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range,
+ _OutIter __result,
+ const _OldType& __old_value,
+ const _NewType& __new_value,
_Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
- return {};
- }
-
-};
+ auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ return ranges::__replace_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
+ }
+ };
} // namespace __replace_copy
@@ -79,6 +86,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_replace_copy_if.h b/libcxx/include/__algorithm/ranges_replace_copy_if.h
index 2a908e2057af..b8741ec7be5e 100644
--- a/libcxx/include/__algorithm/ranges_replace_copy_if.h
+++ b/libcxx/include/__algorithm/ranges_replace_copy_if.h
@@ -10,26 +10,21 @@
#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/replace_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
-#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,34 +33,51 @@ namespace ranges {
template <class _InIter, class _OutIter>
using replace_copy_if_result = in_out_result<_InIter, _OutIter>;
-namespace __replace_copy_if {
-
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter,
- class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
- requires indirectly_copyable<_InIter, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_if_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value,
- _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
- return {};
+template <class _InIter, class _Sent, class _OutIter, class _Pred, class _Type, class _Proj>
+_LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __replace_copy_if_impl(
+ _InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, const _Type& __new_value, _Proj& __proj) {
+ while (__first != __last) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ *__result = __new_value;
+ else
+ *__result = *__first;
+
+ ++__first;
+ ++__result;
}
- template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity,
- indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
- return {};
- }
+ return {std::move(__first), std::move(__result)};
+}
+
+namespace __replace_copy_if {
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ class _Type,
+ output_iterator<const _Type&> _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> operator()(
+ _InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {})
+ const {
+ return ranges::__replace_copy_if_impl(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _Type,
+ output_iterator<const _Type&> _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
+ return ranges::__replace_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
+ }
+ };
} // namespace __replace_copy_if
@@ -76,6 +88,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
diff --git a/libcxx/include/__algorithm/ranges_replace_if.h b/libcxx/include/__algorithm/ranges_replace_if.h
index 0f9555fc35c2..65be3c7d76d5 100644
--- a/libcxx/include/__algorithm/ranges_replace_if.h
+++ b/libcxx/include/__algorithm/ranges_replace_if.h
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -72,6 +72,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
diff --git a/libcxx/include/__algorithm/ranges_reverse.h b/libcxx/include/__algorithm/ranges_reverse.h
index e7555d0f9acd..e2a5d9a8250d 100644
--- a/libcxx/include/__algorithm/ranges_reverse.h
+++ b/libcxx/include/__algorithm/ranges_reverse.h
@@ -22,7 +22,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -78,6 +78,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H
diff --git a/libcxx/include/__algorithm/ranges_reverse_copy.h b/libcxx/include/__algorithm/ranges_reverse_copy.h
index e2da9b484aaf..a84b1ad78050 100644
--- a/libcxx/include/__algorithm/ranges_reverse_copy.h
+++ b/libcxx/include/__algorithm/ranges_reverse_copy.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -62,6 +62,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_rotate.h b/libcxx/include/__algorithm/ranges_rotate.h
new file mode 100644
index 000000000000..91ed4027df2b
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_rotate.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_RANGES_ROTATE_H
+#define _LIBCPP___ALGORITHM_RANGES_ROTATE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/ranges_iterator_concept.h>
+#include <__algorithm/rotate.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/permutable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __rotate {
+
+struct __fn {
+
+ template <class _Iter, class _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) {
+ auto __ret = std::__rotate<_RangeAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <permutable _Iter, sentinel_for<_Iter> _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Iter __middle, _Sent __last) const {
+ return __rotate_fn_impl(std::move(__first), std::move(__middle), std::move(__last));
+ }
+
+ template <forward_range _Range>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle) const {
+ return __rotate_fn_impl(ranges::begin(__range), std::move(__middle), ranges::end(__range));
+ }
+
+};
+
+} // namespace __rotate
+
+inline namespace __cpo {
+ inline constexpr auto rotate = __rotate::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H
diff --git a/libcxx/include/__algorithm/ranges_rotate_copy.h b/libcxx/include/__algorithm/ranges_rotate_copy.h
index d7a282c86750..52f403c16a80 100644
--- a/libcxx/include/__algorithm/ranges_rotate_copy.h
+++ b/libcxx/include/__algorithm/ranges_rotate_copy.h
@@ -23,7 +23,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -63,6 +63,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_sample.h b/libcxx/include/__algorithm/ranges_sample.h
new file mode 100644
index 000000000000..a37cb64fa2bf
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_sample.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_RANGES_SAMPLE_H
+#define _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/sample.h>
+#include <__algorithm/uniform_random_bit_generator_adaptor.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__random/uniform_random_bit_generator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.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
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __sample {
+
+struct __fn {
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen>
+ requires (forward_iterator<_Iter> || random_access_iterator<_OutIter>) &&
+ indirectly_copyable<_Iter, _OutIter> &&
+ uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ _OutIter operator()(_Iter __first, _Sent __last,
+ _OutIter __out_first, iter_difference_t<_Iter> __n, _Gen&& __gen) const {
+ _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
+ return std::__sample<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__out_first), __n, __adapted_gen);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Gen>
+ requires (forward_range<_Range> || random_access_iterator<_OutIter>) &&
+ indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ _OutIter operator()(_Range&& __range, _OutIter __out_first, range_difference_t<_Range> __n, _Gen&& __gen) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range),
+ std::move(__out_first), __n, std::forward<_Gen>(__gen));
+ }
+
+};
+
+} // namespace __sample
+
+inline namespace __cpo {
+ inline constexpr auto sample = __sample::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
diff --git a/libcxx/include/__algorithm/ranges_search.h b/libcxx/include/__algorithm/ranges_search.h
index 0564bbe1f8b3..388d5afa499d 100644
--- a/libcxx/include/__algorithm/ranges_search.h
+++ b/libcxx/include/__algorithm/ranges_search.h
@@ -22,12 +22,13 @@
#include <__ranges/concepts.h>
#include <__ranges/size.h>
#include <__ranges/subrange.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -74,7 +75,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred __pred = {},
@@ -89,7 +90,7 @@ struct __fn {
class _Proj1 = identity,
class _Proj2 = identity>
requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
_Range2&& __range2,
_Pred __pred = {},
@@ -129,6 +130,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H
diff --git a/libcxx/include/__algorithm/ranges_search_n.h b/libcxx/include/__algorithm/ranges_search_n.h
index 29fdbfb1c725..56ec8f33d431 100644
--- a/libcxx/include/__algorithm/ranges_search_n.h
+++ b/libcxx/include/__algorithm/ranges_search_n.h
@@ -25,12 +25,13 @@
#include <__ranges/size.h>
#include <__ranges/subrange.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -52,12 +53,8 @@ struct __fn {
}
if constexpr (random_access_iterator<_Iter1>) {
- auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last,
- __count,
- __value,
- __pred,
- __proj,
- __size);
+ auto __ret = std::__search_n_random_access_impl<_RangeAlgPolicy>(
+ __first, __last, __count, __value, __pred, __proj, __size);
return {std::move(__ret.first), std::move(__ret.second)};
}
}
@@ -75,7 +72,7 @@ struct __fn {
class _Pred = ranges::equal_to,
class _Proj = identity>
requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
subrange<_Iter> operator()(_Iter __first, _Sent __last,
iter_difference_t<_Iter> __count,
const _Type& __value,
@@ -86,7 +83,7 @@ struct __fn {
template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_subrange_t<_Range> operator()(_Range&& __range,
range_difference_t<_Range> __count,
const _Type& __value,
@@ -115,6 +112,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
diff --git a/libcxx/include/__algorithm/ranges_set_difference.h b/libcxx/include/__algorithm/ranges_set_difference.h
index 4eb3efad3895..607dd687a5de 100644
--- a/libcxx/include/__algorithm/ranges_set_difference.h
+++ b/libcxx/include/__algorithm/ranges_set_difference.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/set_difference.h>
#include <__config>
@@ -23,12 +24,13 @@
#include <__ranges/dangling.h>
#include <__type_traits/decay.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -59,7 +61,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_difference(
+ auto __ret = std::__set_difference<_RangeAlgPolicy>(
__first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
return {std::move(__ret.first), std::move(__ret.second)};
}
@@ -71,7 +73,7 @@ struct __fn {
class _Comp = less,
class _Proj1 = identity,
class _Proj2 = identity>
- requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
+ requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
operator()(
_Range1&& __range1,
@@ -80,7 +82,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_difference(
+ auto __ret = std::__set_difference<_RangeAlgPolicy>(
ranges::begin(__range1),
ranges::end(__range1),
ranges::begin(__range2),
@@ -100,5 +102,5 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
diff --git a/libcxx/include/__algorithm/ranges_set_intersection.h b/libcxx/include/__algorithm/ranges_set_intersection.h
index 05af91ae29e5..aa9fd24ced09 100644
--- a/libcxx/include/__algorithm/ranges_set_intersection.h
+++ b/libcxx/include/__algorithm/ranges_set_intersection.h
@@ -28,7 +28,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -82,7 +82,7 @@ struct __fn {
_OutIter,
_Comp,
_Proj1,
- _Proj2>
+ _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,
borrowed_iterator_t<_Range2>,
_OutIter>
@@ -113,5 +113,5 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
diff --git a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h
index c54cf3a65112..bc4a9065503b 100644
--- a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h
+++ b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/set_symmetric_difference.h>
#include <__config>
@@ -27,7 +28,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -58,7 +59,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_symmetric_difference(
+ auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
std::move(__first1),
std::move(__last1),
std::move(__first2),
@@ -81,7 +82,7 @@ struct __fn {
_OutIter,
_Comp,
_Proj1,
- _Proj2>
+ _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,
borrowed_iterator_t<_Range2>,
_OutIter>
@@ -92,7 +93,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_symmetric_difference(
+ auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
ranges::begin(__range1),
ranges::end(__range1),
ranges::begin(__range2),
@@ -112,5 +113,5 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
diff --git a/libcxx/include/__algorithm/ranges_set_union.h b/libcxx/include/__algorithm/ranges_set_union.h
index 3826e55688f7..f8cd45ca0e33 100644
--- a/libcxx/include/__algorithm/ranges_set_union.h
+++ b/libcxx/include/__algorithm/ranges_set_union.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
#include <__algorithm/in_in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/set_union.h>
#include <__config>
@@ -30,7 +31,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -61,7 +62,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_union(
+ auto __ret = std::__set_union<_RangeAlgPolicy>(
std::move(__first1),
std::move(__last1),
std::move(__first2),
@@ -84,7 +85,7 @@ struct __fn {
_OutIter,
_Comp,
_Proj1,
- _Proj2>
+ _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,
borrowed_iterator_t<_Range2>,
_OutIter>
@@ -95,7 +96,7 @@ struct __fn {
_Comp __comp = {},
_Proj1 __proj1 = {},
_Proj2 __proj2 = {}) const {
- auto __ret = std::__set_union(
+ auto __ret = std::__set_union<_RangeAlgPolicy>(
ranges::begin(__range1),
ranges::end(__range1),
ranges::begin(__range2),
@@ -115,6 +116,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
diff --git a/libcxx/include/__algorithm/ranges_shuffle.h b/libcxx/include/__algorithm/ranges_shuffle.h
index b101a8582eac..a2f2c0edded6 100644
--- a/libcxx/include/__algorithm/ranges_shuffle.h
+++ b/libcxx/include/__algorithm/ranges_shuffle.h
@@ -11,6 +11,7 @@
#include <__algorithm/iterator_operations.h>
#include <__algorithm/shuffle.h>
+#include <__algorithm/uniform_random_bit_generator_adaptor.h>
#include <__config>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
@@ -30,10 +31,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -41,34 +39,6 @@ namespace ranges {
namespace __shuffle {
struct __fn {
- // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given
- // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given
- // generator to meet the uniform random bit generator requirements; these requirements include satisfying
- // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type`
- // typedef (see `[rand.req.urng]`).
- //
- // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping
- // it into an adaptor type that forwards all of its interface and adds the required typedef.
- template <class _Gen>
- class _ClassicGenAdaptor {
- private:
- // The generator is not required to be copyable or movable, so it has to be stored as a reference.
- _Gen& __gen;
-
- public:
- using result_type = invoke_result_t<_Gen&>;
-
- _LIBCPP_HIDE_FROM_ABI
- static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
- _LIBCPP_HIDE_FROM_ABI
- static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()() const { return __gen(); }
- };
template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
@@ -96,8 +66,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
diff --git a/libcxx/include/__algorithm/ranges_sort.h b/libcxx/include/__algorithm/ranges_sort.h
index ef14db64295d..32391df5f6d9 100644
--- a/libcxx/include/__algorithm/ranges_sort.h
+++ b/libcxx/include/__algorithm/ranges_sort.h
@@ -31,7 +31,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -44,7 +44,7 @@ struct __fn {
_Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
@@ -74,6 +74,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H
diff --git a/libcxx/include/__algorithm/ranges_sort_heap.h b/libcxx/include/__algorithm/ranges_sort_heap.h
index eb6a30dcd3d0..9feb0f609b25 100644
--- a/libcxx/include/__algorithm/ranges_sort_heap.h
+++ b/libcxx/include/__algorithm/ranges_sort_heap.h
@@ -32,7 +32,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,7 +45,7 @@ struct __fn {
_Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__sort_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
@@ -75,6 +75,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
diff --git a/libcxx/include/__algorithm/ranges_stable_partition.h b/libcxx/include/__algorithm/ranges_stable_partition.h
index 27957db8829f..c3469f17c7d7 100644
--- a/libcxx/include/__algorithm/ranges_stable_partition.h
+++ b/libcxx/include/__algorithm/ranges_stable_partition.h
@@ -34,7 +34,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,11 +45,11 @@ struct __fn {
template <class _Iter, class _Sent, class _Proj, class _Pred>
_LIBCPP_HIDE_FROM_ABI static
- subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl(
+ subrange<__remove_cvref_t<_Iter>> __stable_partition_fn_impl(
_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_pred = ranges::__make_projected_pred(__pred, __proj);
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
auto __result = std::__stable_partition<_RangeAlgPolicy>(
std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
@@ -83,6 +83,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
diff --git a/libcxx/include/__algorithm/ranges_stable_sort.h b/libcxx/include/__algorithm/ranges_stable_sort.h
index de48416a41be..d3c48ddb9b8e 100644
--- a/libcxx/include/__algorithm/ranges_stable_sort.h
+++ b/libcxx/include/__algorithm/ranges_stable_sort.h
@@ -31,7 +31,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -44,7 +44,7 @@ struct __fn {
static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
@@ -74,6 +74,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
diff --git a/libcxx/include/__algorithm/ranges_swap_ranges.h b/libcxx/include/__algorithm/ranges_swap_ranges.h
index 3254e1c60abb..552fd55ff88f 100644
--- a/libcxx/include/__algorithm/ranges_swap_ranges.h
+++ b/libcxx/include/__algorithm/ranges_swap_ranges.h
@@ -10,6 +10,8 @@
#define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
#include <__algorithm/in_in_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/swap_ranges.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iter_swap.h>
@@ -22,7 +24,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,12 +40,9 @@ struct __fn {
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)};
+ auto __ret = std::__swap_ranges<_RangeAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2));
+ return {std::move(__ret.first), std::move(__ret.second)};
}
template <input_range _R1, input_range _R2>
@@ -64,6 +63,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
diff --git a/libcxx/include/__algorithm/ranges_transform.h b/libcxx/include/__algorithm/ranges_transform.h
index 3c13b1b79ff3..c0981a04a9bb 100644
--- a/libcxx/include/__algorithm/ranges_transform.h
+++ b/libcxx/include/__algorithm/ranges_transform.h
@@ -26,7 +26,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -165,6 +165,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
diff --git a/libcxx/include/__algorithm/ranges_unique.h b/libcxx/include/__algorithm/ranges_unique.h
index bdf755e9406e..be427ccf7fad 100644
--- a/libcxx/include/__algorithm/ranges_unique.h
+++ b/libcxx/include/__algorithm/ranges_unique.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/unique.h>
#include <__config>
@@ -25,40 +26,44 @@
#include <__ranges/subrange.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __unique {
-struct __fn {
+ struct __fn {
+ template <
+ permutable _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
- template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
- indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
- _LIBCPP_HIDE_FROM_ABI constexpr
- subrange<_Iter> operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__comp; (void)__proj;
- return {};
- }
-
- template <forward_range _Range, class _Proj = identity,
- indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
- requires permutable<iterator_t<_Range>>
- _LIBCPP_HIDE_FROM_ABI constexpr
- borrowed_subrange_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__comp; (void)__proj;
- return {};
- }
-
-};
+ template <
+ forward_range _Range,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+ };
} // namespace __unique
@@ -69,6 +74,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
diff --git a/libcxx/include/__algorithm/ranges_unique_copy.h b/libcxx/include/__algorithm/ranges_unique_copy.h
index 56361aa8ae2f..3ad47b06f5db 100644
--- a/libcxx/include/__algorithm/ranges_unique_copy.h
+++ b/libcxx/include/__algorithm/ranges_unique_copy.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/unique_copy.h>
#include <__concepts/same_as.h>
@@ -19,19 +20,20 @@
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
-#include <__iterator/readable_traits.h>
#include <__iterator/projected.h>
+#include <__iterator/readable_traits.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -42,47 +44,73 @@ using unique_copy_result = in_out_result<_InIter, _OutIter>;
namespace __unique_copy {
+template <class _InIter, class _OutIter>
+concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);
+
struct __fn {
+ template <class _InIter, class _OutIter>
+ static consteval auto __get_algo_tag() {
+ if constexpr (forward_iterator<_InIter>) {
+ return __unique_copy_tags::__reread_from_input_tag{};
+ } else if constexpr (__can_reread_from_output<_InIter, _OutIter>) {
+ return __unique_copy_tags::__reread_from_output_tag{};
+ } else if constexpr (indirectly_copyable_storable<_InIter, _OutIter>) {
+ return __unique_copy_tags::__read_from_tmp_value_tag{};
+ }
+ }
+
+ template <class _InIter, class _OutIter>
+ using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Proj = identity,
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
indirect_equivalence_relation<projected<_InIter, _Proj>> _Comp = ranges::equal_to>
- requires indirectly_copyable<_InIter, _OutIter> &&
- (forward_iterator<_InIter> ||
- (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
- indirectly_copyable_storable<_InIter, _OutIter>)
- _LIBCPP_HIDE_FROM_ABI constexpr
- unique_copy_result<_InIter, _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ (forward_iterator<_InIter> ||
+ (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<_InIter, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter>
operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__comp; (void)__proj;
- return {};
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ std::move(__first),
+ std::move(__last),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<_InIter, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
}
- template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- (forward_iterator<iterator_t<_Range>> ||
- (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
- indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
- _LIBCPP_HIDE_FROM_ABI constexpr
- unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ (forward_iterator<iterator_t<_Range>> ||
+ (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__comp; (void)__proj;
- return {};
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ ranges::begin(__range),
+ ranges::end(__range),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<iterator_t<_Range>, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
}
-
};
} // namespace __unique_copy
inline namespace __cpo {
- inline constexpr auto unique_copy = __unique_copy::__fn{};
+inline constexpr auto unique_copy = __unique_copy::__fn{};
} // namespace __cpo
} // namespace ranges
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
diff --git a/libcxx/include/__algorithm/ranges_upper_bound.h b/libcxx/include/__algorithm/ranges_upper_bound.h
index 3c63249248fa..a1340809048c 100644
--- a/libcxx/include/__algorithm/ranges_upper_bound.h
+++ b/libcxx/include/__algorithm/ranges_upper_bound.h
@@ -25,7 +25,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -34,7 +34,7 @@ namespace __upper_bound {
struct __fn {
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
_Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
return !std::invoke(__comp, __rhs, __lhs);
@@ -45,7 +45,7 @@ struct __fn {
template <forward_range _Range, class _Type, class _Proj = identity,
indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
- _LIBCPP_HIDE_FROM_ABI constexpr
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __r,
const _Type& __value,
_Comp __comp = {},
@@ -70,6 +70,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
diff --git a/libcxx/include/__algorithm/remove.h b/libcxx/include/__algorithm/remove.h
index 8a7e99ba09a1..533e41b54fa4 100644
--- a/libcxx/include/__algorithm/remove.h
+++ b/libcxx/include/__algorithm/remove.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
__first = _VSTD::find(__first, __last, __value);
diff --git a/libcxx/include/__algorithm/remove_copy.h b/libcxx/include/__algorithm/remove_copy.h
index 55fc1d90a1e7..ecba08a053e6 100644
--- a/libcxx/include/__algorithm/remove_copy.h
+++ b/libcxx/include/__algorithm/remove_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
{
diff --git a/libcxx/include/__algorithm/remove_copy_if.h b/libcxx/include/__algorithm/remove_copy_if.h
index 36ddba4883ab..2f235fd32ff6 100644
--- a/libcxx/include/__algorithm/remove_copy_if.h
+++ b/libcxx/include/__algorithm/remove_copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
{
diff --git a/libcxx/include/__algorithm/remove_if.h b/libcxx/include/__algorithm/remove_if.h
index 0ae131498d22..27350728d256 100644
--- a/libcxx/include/__algorithm/remove_if.h
+++ b/libcxx/include/__algorithm/remove_if.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
__first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
diff --git a/libcxx/include/__algorithm/replace.h b/libcxx/include/__algorithm/replace.h
index d0ae8f65d4a2..ce6215066f51 100644
--- a/libcxx/include/__algorithm/replace.h
+++ b/libcxx/include/__algorithm/replace.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
{
diff --git a/libcxx/include/__algorithm/replace_copy.h b/libcxx/include/__algorithm/replace_copy.h
index 7c8a5a0b93cb..bebb14cbe210 100644
--- a/libcxx/include/__algorithm/replace_copy.h
+++ b/libcxx/include/__algorithm/replace_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
const _Tp& __old_value, const _Tp& __new_value)
diff --git a/libcxx/include/__algorithm/replace_copy_if.h b/libcxx/include/__algorithm/replace_copy_if.h
index 9d8a68fdc0f3..e1ddb527be84 100644
--- a/libcxx/include/__algorithm/replace_copy_if.h
+++ b/libcxx/include/__algorithm/replace_copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_Predicate __pred, const _Tp& __new_value)
diff --git a/libcxx/include/__algorithm/replace_if.h b/libcxx/include/__algorithm/replace_if.h
index 37c719a34c84..b3a3367d2233 100644
--- a/libcxx/include/__algorithm/replace_if.h
+++ b/libcxx/include/__algorithm/replace_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
{
diff --git a/libcxx/include/__algorithm/reverse.h b/libcxx/include/__algorithm/reverse.h
index 0202cd740833..aa76951707a3 100644
--- a/libcxx/include/__algorithm/reverse.h
+++ b/libcxx/include/__algorithm/reverse.h
@@ -10,8 +10,10 @@
#define _LIBCPP___ALGORITHM_REVERSE_H
#include <__algorithm/iter_swap.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -19,36 +21,43 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+template <class _AlgPolicy, class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
-__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
+__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
{
while (__first != __last)
{
if (__first == --__last)
break;
- _VSTD::iter_swap(__first, __last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
++__first;
}
}
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+template <class _AlgPolicy, class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
-__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
+__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
{
if (__first != __last)
for (; __first < --__last; ++__first)
- _VSTD::iter_swap(__first, __last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+}
+
+template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+void __reverse(_BidirectionalIterator __first, _Sentinel __last) {
+ using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>;
+ std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory());
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
- _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
+ std::__reverse<_ClassicAlgPolicy>(std::move(__first), std::move(__last));
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/reverse_copy.h b/libcxx/include/__algorithm/reverse_copy.h
index 158390707803..f4a0e9713dd5 100644
--- a/libcxx/include/__algorithm/reverse_copy.h
+++ b/libcxx/include/__algorithm/reverse_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
{
diff --git a/libcxx/include/__algorithm/rotate.h b/libcxx/include/__algorithm/rotate.h
index fcf8444a65a0..8934ce095bbc 100644
--- a/libcxx/include/__algorithm/rotate.h
+++ b/libcxx/include/__algorithm/rotate.h
@@ -15,10 +15,8 @@
#include <__algorithm/swap_ranges.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__iterator/next.h>
-#include <__iterator/prev.h>
#include <__utility/move.h>
-#include <__utility/swap.h>
+#include <__utility/pair.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -28,33 +26,35 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first);
- // TODO(ranges): pass `_AlgPolicy` to `move`.
- _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ value_type __tmp = _Ops::__iter_move(__first);
+ _ForwardIterator __lm1 = std::__move<_AlgPolicy>(
+ _Ops::next(__first), __last, __first).second;
*__lm1 = _VSTD::move(__tmp);
return __lm1;
}
template <class _AlgPolicy, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- // TODO(ranges): pass `_AlgPolicy` to `prev`.
- _BidirectionalIterator __lm1 = _VSTD::prev(__last);
- value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1);
- // TODO(ranges): pass `_AlgPolicy` to `move_backward`.
- _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ _BidirectionalIterator __lm1 = _Ops::prev(__last);
+ value_type __tmp = _Ops::__iter_move(__lm1);
+ _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)).second;
*__first = _VSTD::move(__tmp);
return __fp1;
}
template <class _AlgPolicy, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _ForwardIterator
__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
_ForwardIterator __i = __middle;
@@ -90,7 +90,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
+_LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral
__algo_gcd(_Integral __x, _Integral __y)
{
do
@@ -103,31 +103,31 @@ __algo_gcd(_Integral __x, _Integral __y)
}
template <class _AlgPolicy, typename _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _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;
+ using _Ops = _IterOps<_AlgPolicy>;
const difference_type __m1 = __middle - __first;
- const difference_type __m2 = __last - __middle;
+ const difference_type __m2 = _Ops::distance(__middle, __last);
if (__m1 == __m2)
{
- // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`.
- _VSTD::swap_ranges(__first, __middle, __middle);
+ std::__swap_ranges<_AlgPolicy>(__first, __middle, __middle, __last);
return __middle;
}
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
- value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p));
+ value_type __t(_Ops::__iter_move(--__p));
_RandomAccessIterator __p1 = __p;
_RandomAccessIterator __p2 = __p1 + __m1;
do
{
- *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2);
+ *__p1 = _Ops::__iter_move(__p2);
__p1 = __p2;
- const difference_type __d = __last - __p2;
+ const difference_type __d = _Ops::distance(__p2, __last);
if (__m1 < __d)
__p2 += __m1;
else
@@ -140,7 +140,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
template <class _AlgPolicy, class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
_VSTD::forward_iterator_tag)
{
@@ -155,7 +155,7 @@ __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardItera
template <class _AlgPolicy, class _BidirectionalIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
bidirectional_iterator_tag)
{
@@ -172,7 +172,7 @@ __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
template <class _AlgPolicy, class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
random_access_iterator_tag)
{
@@ -188,25 +188,32 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra
return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
}
-template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-_RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle,
- _RandomAccessIterator __last, _IterCategory __iter_category) {
+template <class _AlgPolicy, class _Iterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+pair<_Iterator, _Iterator>
+__rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
+ using _Ret = pair<_Iterator, _Iterator>;
+ _Iterator __last_iter = _IterOps<_AlgPolicy>::next(__middle, __last);
+
if (__first == __middle)
- return __last;
+ return _Ret(__last_iter, __last_iter);
if (__middle == __last)
- return __first;
+ return _Ret(std::move(__first), std::move(__last_iter));
+
+ using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_Iterator>;
+ auto __result = std::__rotate_impl<_AlgPolicy>(
+ std::move(__first), std::move(__middle), __last_iter, _IterCategory());
- return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category);
+ return _Ret(std::move(__result), std::move(__last_iter));
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
- return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last,
- typename iterator_traits<_ForwardIterator>::iterator_category());
+ return std::__rotate<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last)).first;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/rotate_copy.h b/libcxx/include/__algorithm/rotate_copy.h
index ab569ef7c6be..c154649ab98c 100644
--- a/libcxx/include/__algorithm/rotate_copy.h
+++ b/libcxx/include/__algorithm/rotate_copy.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
{
diff --git a/libcxx/include/__algorithm/sample.h b/libcxx/include/__algorithm/sample.h
index e04466a08d5a..f403ba612580 100644
--- a/libcxx/include/__algorithm/sample.h
+++ b/libcxx/include/__algorithm/sample.h
@@ -9,12 +9,14 @@
#ifndef _LIBCPP___ALGORITHM_SAMPLE_H
#define _LIBCPP___ALGORITHM_SAMPLE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -26,13 +28,14 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
- _UniformRandomNumberGenerator & __g,
+ _UniformRandomNumberGenerator& __g,
input_iterator_tag) {
_Distance __k = 0;
@@ -47,15 +50,16 @@ _SampleIterator __sample(_PopulationIterator __first,
return __output_iter + _VSTD::min(__n, __k);
}
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
_UniformRandomNumberGenerator& __g,
forward_iterator_tag) {
- _Distance __unsampled_sz = _VSTD::distance(__first, __last);
+ _Distance __unsampled_sz = _IterOps<_AlgPolicy>::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) {
@@ -66,24 +70,22 @@ _SampleIterator __sample(_PopulationIterator __first,
return __output_iter;
}
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __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());
+
+ using _PopIterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_PopulationIterator>;
+ using _Difference = typename _IterOps<_AlgPolicy>::template __difference_type<_PopulationIterator>;
+ using _CommonType = typename common_type<_Distance, _Difference>::type;
+
+ return std::__sample<_AlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__output_iter), _CommonType(__n),
+ __g, _PopIterCategory());
}
#if _LIBCPP_STD_VER > 14
@@ -93,8 +95,14 @@ 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);
+ static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
+ __is_cpp17_random_access_iterator<_SampleIterator>::value,
+ "SampleIterator must meet the requirements of RandomAccessIterator");
+
+ return std::__sample<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__output_iter), __n, __g);
}
+
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/search.h b/libcxx/include/__algorithm/search.h
index 4ead6cac82b7..93771be39e35 100644
--- a/libcxx/include/__algorithm/search.h
+++ b/libcxx/include/__algorithm/search.h
@@ -33,7 +33,7 @@ template <class _AlgPolicy,
class _Pred,
class _Proj1,
class _Proj2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred& __pred,
@@ -80,7 +80,7 @@ template <class _AlgPolicy,
class _Proj2,
class _DiffT1,
class _DiffT2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred& __pred,
@@ -120,7 +120,7 @@ template <class _Iter1, class _Sent1,
class _Pred,
class _Proj1,
class _Proj2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred& __pred,
@@ -152,7 +152,7 @@ template <class _Iter1, class _Sent1,
class _Pred,
class _Proj1,
class _Proj2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
_Iter2 __first2, _Sent2 __last2,
_Pred& __pred,
@@ -170,7 +170,7 @@ pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred) {
@@ -181,17 +181,15 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2) {
- using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
- using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
- return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+ return std::search(__first1, __last1, __first2, __last2, __equal_to());
}
#if _LIBCPP_STD_VER > 14
template <class _ForwardIterator, class _Searcher>
-_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
return __s(__f, __l).first;
}
diff --git a/libcxx/include/__algorithm/search_n.h b/libcxx/include/__algorithm/search_n.h
index ccb8e845f5b1..60a073565156 100644
--- a/libcxx/include/__algorithm/search_n.h
+++ b/libcxx/include/__algorithm/search_n.h
@@ -19,6 +19,7 @@
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/concepts.h>
+#include <__utility/convert_to_integral.h>
#include <__utility/pair.h>
#include <type_traits> // __convert_to_integral
@@ -29,7 +30,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
_SizeT __count,
const _Type& __value,
@@ -71,7 +72,7 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
}
template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
_SizeT __count,
const _Type& __value,
@@ -122,7 +123,7 @@ template <class _Iter, class _Sent,
class _Type,
class _Pred,
class _Proj>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
_DiffT __count,
const _Type& __value,
@@ -142,7 +143,7 @@ template <class _Iter1, class _Sent1,
class _Type,
class _Pred,
class _Proj>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
_DiffT __count,
const _Type& __value,
@@ -158,7 +159,7 @@ pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
}
template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count,
const _Tp& __value,
@@ -170,10 +171,9 @@ _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
}
template <class _ForwardIterator, class _Size, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>());
+ return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/set_difference.h b/libcxx/include/__algorithm/set_difference.h
index 4378bd5304d9..cffdc8fc4fc0 100644
--- a/libcxx/include/__algorithm/set_difference.h
+++ b/libcxx/include/__algorithm/set_difference.h
@@ -12,6 +12,7 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
@@ -26,8 +27,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<__uncvref_t<_InIter1>, __uncvref_t<_OutIter> >
+template <class _AlgPolicy, class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
__set_difference(
_InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
while (__first1 != __last1 && __first2 != __last2) {
@@ -42,29 +43,30 @@ __set_difference(
++__first2;
}
}
- return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
+ return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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 std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second;
+ return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
+ __first1, __last1, __first2, __last2, __result, __comp)
+ .second;
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_difference(
_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
_InputIterator2 __last2,
_OutputIterator __result) {
- return std::__set_difference(
+ return std::__set_difference<_ClassicAlgPolicy>(
__first1,
__last1,
__first2,
diff --git a/libcxx/include/__algorithm/set_intersection.h b/libcxx/include/__algorithm/set_intersection.h
index 77cc83738d1f..9fa7799aee62 100644
--- a/libcxx/include/__algorithm/set_intersection.h
+++ b/libcxx/include/__algorithm/set_intersection.h
@@ -30,13 +30,13 @@ struct __set_intersection_result {
_OutIter __out_;
// need a constructor as C++03 aggregate init is hard
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
__set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
: __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
};
template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_intersection_result<_InIter1, _InIter2, _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
__set_intersection(
_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
while (__first1 != __last1 && __first2 != __last2) {
@@ -59,15 +59,14 @@ __set_intersection(
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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 std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>(
+ return std::__set_intersection<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
std::move(__first1),
std::move(__last1),
std::move(__first2),
@@ -78,7 +77,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_i
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection(
_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
diff --git a/libcxx/include/__algorithm/set_symmetric_difference.h b/libcxx/include/__algorithm/set_symmetric_difference.h
index cd532ab5800d..bcb09587032b 100644
--- a/libcxx/include/__algorithm/set_symmetric_difference.h
+++ b/libcxx/include/__algorithm/set_symmetric_difference.h
@@ -12,9 +12,11 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,18 +31,18 @@ struct __set_symmetric_difference_result {
_OutIter __out_;
// need a constructor as C++03 aggregate init is hard
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
__set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
: __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
};
-template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
+template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
__set_symmetric_difference(
_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
while (__first1 != __last1) {
if (__first2 == __last2) {
- auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
+ auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
}
@@ -58,21 +60,20 @@ __set_symmetric_difference(
++__first2;
}
}
- auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
+ auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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 std::__set_symmetric_difference<_Comp_ref>(
+ return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
std::move(__first1),
std::move(__last1),
std::move(__first2),
@@ -83,7 +84,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetri
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetric_difference(
_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
diff --git a/libcxx/include/__algorithm/set_union.h b/libcxx/include/__algorithm/set_union.h
index 3bd437980161..4d154b81e092 100644
--- a/libcxx/include/__algorithm/set_union.h
+++ b/libcxx/include/__algorithm/set_union.h
@@ -12,9 +12,11 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,17 +31,17 @@ struct __set_union_result {
_OutIter __out_;
// need a constructor as C++03 aggregate init is hard
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
__set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
: __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
};
-template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
+template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
for (; __first1 != __last1; ++__result) {
if (__first2 == __last2) {
- auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
+ auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
return __set_union_result<_InIter1, _InIter2, _OutIter>(
std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
}
@@ -54,21 +56,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1,
++__first1;
}
}
- auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
+ auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
return __set_union_result<_InIter1, _InIter2, _OutIter>(
std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _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 std::__set_union<_Comp_ref>(
+ return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
std::move(__first1),
std::move(__last1),
std::move(__first2),
@@ -79,7 +80,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(
_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2,
diff --git a/libcxx/include/__algorithm/shuffle.h b/libcxx/include/__algorithm/shuffle.h
index e32c6a7608ba..f7bce68697b5 100644
--- a/libcxx/include/__algorithm/shuffle.h
+++ b/libcxx/include/__algorithm/shuffle.h
@@ -16,6 +16,7 @@
#include <__random/uniform_int_distribution.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/swap.h>
#include <cstddef>
#include <cstdint>
@@ -31,9 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
public:
__libcpp_debug_randomizer() {
- __state = __seed();
- __inc = __state + 0xda3e39cb94b95bdbULL;
- __inc = (__inc << 1) | 1;
+ __state_ = __seed();
+ __inc_ = __state_ + 0xda3e39cb94b95bdbULL;
+ __inc_ = (__inc_ << 1) | 1;
}
typedef uint_fast32_t result_type;
@@ -41,8 +42,8 @@ public:
static const result_type _Max = 0xFFFFFFFF;
_LIBCPP_HIDE_FROM_ABI result_type operator()() {
- uint_fast64_t __oldstate = __state;
- __state = __oldstate * 6364136223846793005ULL + __inc;
+ uint_fast64_t __oldstate = __state_;
+ __state_ = __oldstate * 6364136223846793005ULL + __inc_;
return __oldstate >> 32;
}
@@ -50,8 +51,8 @@ public:
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; }
private:
- uint_fast64_t __state;
- uint_fast64_t __inc;
+ 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;
@@ -93,7 +94,7 @@ public:
_LIBCPP_FUNC_VIS __rs_default __rs_get();
template <class _RandomAccessIterator>
-_LIBCPP_DEPRECATED_IN_CXX14 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -114,7 +115,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
}
template <class _RandomAccessIterator, class _RandomNumberGenerator>
-_LIBCPP_DEPRECATED_IN_CXX14 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
#ifndef _LIBCPP_CXX03_LANG
_RandomNumberGenerator&& __rand)
@@ -137,7 +138,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
#endif
template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
-_RandomAccessIterator __shuffle(
+_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator __shuffle(
_RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef uniform_int_distribution<ptrdiff_t> _Dp;
@@ -161,8 +162,8 @@ _RandomAccessIterator __shuffle(
}
template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
-void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _UniformRandomNumberGenerator&& __g) {
+_LIBCPP_HIDE_FROM_ABI void
+shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRandomNumberGenerator&& __g) {
(void)std::__shuffle<_ClassicAlgPolicy>(
std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
}
diff --git a/libcxx/include/__algorithm/sift_down.h b/libcxx/include/__algorithm/sift_down.h
index be2eb29dd53a..e3972fb6f46e 100644
--- a/libcxx/include/__algorithm/sift_down.h
+++ b/libcxx/include/__algorithm/sift_down.h
@@ -22,8 +22,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__sift_down(_RandomAccessIterator __first, _Compare __comp,
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
+__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{
@@ -78,8 +78,8 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
-__floyd_sift_down(_RandomAccessIterator __first, _Compare __comp,
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
+__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
{
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 1ca2f1b81712..a7d2d55a06f8 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -11,19 +11,29 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iter_swap.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/min_element.h>
#include <__algorithm/partial_sort.h>
#include <__algorithm/unwrap_iter.h>
-#include <__bits>
+#include <__assert>
+#include <__bit/blsr.h>
+#include <__bit/countl.h>
+#include <__bit/countr.h>
#include <__config>
#include <__debug>
#include <__debug_utils/randomize_range.h>
#include <__functional/operations.h>
#include <__functional/ranges_operations.h>
#include <__iterator/iterator_traits.h>
+#include <__memory/destruct_n.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#include <climits>
-#include <memory>
+#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -43,7 +53,7 @@ struct _WrapAlgPolicy {
using _Comp = _CompT;
_Comp& __comp;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_WrapAlgPolicy(_Comp& __c) : __comp(__c) {}
};
@@ -62,7 +72,7 @@ struct _UnwrapAlgPolicy {
using _AlgPolicy = _ClassicAlgPolicy;
using _Comp = _CompT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
_Comp __get_comp(_Comp __comp) { return __comp; }
};
@@ -73,14 +83,15 @@ struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {
using _AlgPolicy = typename _Wrapped::_AlgPolicy;
using _Comp = typename _Wrapped::_Comp;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
_Comp __get_comp(_Wrapped& __w) { return __w.__comp; }
};
// stable, 2-3 compares, 0-2 swaps
template <class _AlgPolicy, class _Compare, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX14 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
_Compare __c) {
using _Ops = _IterOps<_AlgPolicy>;
@@ -118,10 +129,10 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIte
// stable, 3-6 compares, 0-5 swaps
template <class _AlgPolicy, class _Compare, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI
unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
_Compare __c) {
- using _Ops = _IterOps<_AlgPolicy>;
-
+ using _Ops = _IterOps<_AlgPolicy>;
unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
if (__c(*__x4, *__x3)) {
_Ops::iter_swap(__x3, __x4);
@@ -171,12 +182,12 @@ _LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _F
}
template <class _AlgPolicy, class _Compare, class _ForwardIterator>
-_LIBCPP_HIDDEN unsigned __sort5_wrap_policy(
+_LIBCPP_HIDE_FROM_ABI unsigned __sort5_wrap_policy(
_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,
_Compare __c) {
using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
_WrappedComp __wrapped_comp(__c);
- return std::__sort5<_WrappedComp>(
+ return std::__sort5<_WrappedComp, _ForwardIterator>(
std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);
}
@@ -201,6 +212,13 @@ using __use_branchless_sort =
integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&
is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;
+namespace __detail {
+
+// Size in bits for the bitset in use.
+enum { __block_size = sizeof(uint64_t) * 8 };
+
+} // namespace __detail
+
// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
template <class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
@@ -231,8 +249,8 @@ template <class, class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_Compare __c) {
- _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
- _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
+ std::__cond_swap<_Compare>(__x2, __x3, __c);
+ std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
@@ -246,11 +264,11 @@ template <class, class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _Compare __c) {
- _VSTD::__cond_swap<_Compare>(__x1, __x3, __c);
- _VSTD::__cond_swap<_Compare>(__x2, __x4, __c);
- _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
- _VSTD::__cond_swap<_Compare>(__x3, __x4, __c);
- _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
+ std::__cond_swap<_Compare>(__x1, __x3, __c);
+ std::__cond_swap<_Compare>(__x2, __x4, __c);
+ std::__cond_swap<_Compare>(__x1, __x2, __c);
+ std::__cond_swap<_Compare>(__x3, __x4, __c);
+ std::__cond_swap<_Compare>(__x2, __x3, __c);
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
@@ -260,16 +278,21 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
}
-template <class, class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
-__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
- _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
- _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
- _VSTD::__cond_swap<_Compare>(__x4, __x5, __c);
- _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
- _VSTD::__cond_swap<_Compare>(__x2, __x5, __c);
- _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
- _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
+__sort5_maybe_branchless(
+ _RandomAccessIterator __x1,
+ _RandomAccessIterator __x2,
+ _RandomAccessIterator __x3,
+ _RandomAccessIterator __x4,
+ _RandomAccessIterator __x5,
+ _Compare __c) {
+ std::__cond_swap<_Compare>(__x1, __x2, __c);
+ std::__cond_swap<_Compare>(__x4, __x5, __c);
+ std::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
+ std::__cond_swap<_Compare>(__x2, __x5, __c);
+ std::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
+ std::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
@@ -281,7 +304,8 @@ __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
// Assumes size > 0
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX14 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
_Compare __comp) {
_BidirectionalIterator __lm1 = __last;
for (--__lm1; __first != __lm1; ++__first) {
@@ -291,32 +315,48 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __fir
}
}
+// Sort the iterator range [__first, __last) using the comparator __comp using
+// the insertion sort algorithm.
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+_LIBCPP_HIDE_FROM_ABI
void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
using _Ops = _IterOps<_AlgPolicy>;
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(_Ops::__iter_move(__j));
- for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
+ if (__first == __last)
+ return;
+ _BidirectionalIterator __i = __first;
+ for (++__i; __i != __last; ++__i) {
+ _BidirectionalIterator __j = __i;
+ --__j;
+ if (__comp(*__i, *__j)) {
+ value_type __t(_Ops::__iter_move(__i));
+ _BidirectionalIterator __k = __j;
+ __j = __i;
+ do {
*__j = _Ops::__iter_move(__k);
- *__j = _VSTD::move(__t);
+ __j = __k;
+ } while (__j != __first && __comp(__t, *--__k));
+ *__j = std::move(__t);
}
}
}
+// Sort the iterator range [__first, __last) using the comparator __comp using
+// the insertion sort algorithm. Insertion sort has two loops, outer and inner.
+// The implementation below has not bounds check (unguarded) for the inner loop.
+// Assumes that there is an element in the position (__first - 1) and that each
+// element in the input range is greater or equal to the element at __first - 1.
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+_LIBCPP_HIDE_FROM_ABI void
+__insertion_sort_unguarded(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
using _Ops = _IterOps<_AlgPolicy>;
-
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first + difference_type(2);
- std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
- for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
+ if (__first == __last)
+ return;
+ for (_RandomAccessIterator __i = __first + difference_type(1); __i != __last; ++__i) {
+ _RandomAccessIterator __j = __i - difference_type(1);
if (__comp(*__i, *__j)) {
value_type __t(_Ops::__iter_move(__i));
_RandomAccessIterator __k = __j;
@@ -324,15 +364,14 @@ void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __l
do {
*__j = _Ops::__iter_move(__k);
__j = __k;
- } while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
+ } while (__comp(__t, *--__k)); // No need for bounds check due to the assumption stated above.
+ *__j = std::move(__t);
}
- __j = __i;
}
}
template <class _WrappedComp, class _RandomAccessIterator>
-bool __insertion_sort_incomplete(
+_LIBCPP_HIDDEN bool __insertion_sort_incomplete(
_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
using _AlgPolicy = typename _Unwrap::_AlgPolicy;
@@ -348,7 +387,7 @@ bool __insertion_sort_incomplete(
return true;
case 2:
if (__comp(*--__last, *__first))
- _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+ _Ops::iter_swap(__first, __last);
return true;
case 3:
std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
@@ -377,7 +416,7 @@ bool __insertion_sort_incomplete(
*__j = _Ops::__iter_move(__k);
__j = __k;
} while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
+ *__j = std::move(__t);
if (++__count == __limit)
return ++__i == __last;
}
@@ -387,6 +426,7 @@ bool __insertion_sort_incomplete(
}
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
+_LIBCPP_HIDE_FROM_ABI
void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {
using _Ops = _IterOps<_AlgPolicy>;
@@ -416,17 +456,336 @@ void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterat
}
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __depth) {
+template <class _AlgPolicy, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(
+ _RandomAccessIterator __first, _RandomAccessIterator __last, uint64_t& __left_bitset, uint64_t& __right_bitset) {
+ using _Ops = _IterOps<_AlgPolicy>;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ // Swap one pair on each iteration as long as both bitsets have at least one
+ // element for swapping.
+ while (__left_bitset != 0 && __right_bitset != 0) {
+ difference_type tz_left = __libcpp_ctz(__left_bitset);
+ __left_bitset = __libcpp_blsr(__left_bitset);
+ difference_type tz_right = __libcpp_ctz(__right_bitset);
+ __right_bitset = __libcpp_blsr(__right_bitset);
+ _Ops::iter_swap(__first + tz_left, __last - tz_right);
+ }
+}
+
+template <class _Compare,
+ class _RandomAccessIterator,
+ class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
+inline _LIBCPP_HIDE_FROM_ABI void
+__populate_left_bitset(_RandomAccessIterator __first, _Compare __comp, _ValueType& __pivot, uint64_t& __left_bitset) {
+ // Possible vectorization. With a proper "-march" flag, the following loop
+ // will be compiled into a set of SIMD instructions.
+ _RandomAccessIterator __iter = __first;
+ for (int __j = 0; __j < __detail::__block_size;) {
+ bool __comp_result = !__comp(*__iter, __pivot);
+ __left_bitset |= (static_cast<uint64_t>(__comp_result) << __j);
+ __j++;
+ ++__iter;
+ }
+}
+
+template <class _Compare,
+ class _RandomAccessIterator,
+ class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
+inline _LIBCPP_HIDE_FROM_ABI void
+__populate_right_bitset(_RandomAccessIterator __lm1, _Compare __comp, _ValueType& __pivot, uint64_t& __right_bitset) {
+ // Possible vectorization. With a proper "-march" flag, the following loop
+ // will be compiled into a set of SIMD instructions.
+ _RandomAccessIterator __iter = __lm1;
+ for (int __j = 0; __j < __detail::__block_size;) {
+ bool __comp_result = __comp(*__iter, __pivot);
+ __right_bitset |= (static_cast<uint64_t>(__comp_result) << __j);
+ __j++;
+ --__iter;
+ }
+}
+
+template <class _AlgPolicy,
+ class _Compare,
+ class _RandomAccessIterator,
+ class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
+inline _LIBCPP_HIDE_FROM_ABI void __bitset_partition_partial_blocks(
+ _RandomAccessIterator& __first,
+ _RandomAccessIterator& __lm1,
+ _Compare __comp,
+ _ValueType& __pivot,
+ uint64_t& __left_bitset,
+ uint64_t& __right_bitset) {
+ typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __remaining_len = __lm1 - __first + 1;
+ difference_type __l_size;
+ difference_type __r_size;
+ if (__left_bitset == 0 && __right_bitset == 0) {
+ __l_size = __remaining_len / 2;
+ __r_size = __remaining_len - __l_size;
+ } else if (__left_bitset == 0) {
+ // We know at least one side is a full block.
+ __l_size = __remaining_len - __detail::__block_size;
+ __r_size = __detail::__block_size;
+ } else { // if (__right_bitset == 0)
+ __l_size = __detail::__block_size;
+ __r_size = __remaining_len - __detail::__block_size;
+ }
+ // Record the comparison outcomes for the elements currently on the left side.
+ if (__left_bitset == 0) {
+ _RandomAccessIterator __iter = __first;
+ for (int j = 0; j < __l_size; j++) {
+ bool __comp_result = !__comp(*__iter, __pivot);
+ __left_bitset |= (static_cast<uint64_t>(__comp_result) << j);
+ ++__iter;
+ }
+ }
+ // Record the comparison outcomes for the elements currently on the right
+ // side.
+ if (__right_bitset == 0) {
+ _RandomAccessIterator __iter = __lm1;
+ for (int j = 0; j < __r_size; j++) {
+ bool __comp_result = __comp(*__iter, __pivot);
+ __right_bitset |= (static_cast<uint64_t>(__comp_result) << j);
+ --__iter;
+ }
+ }
+ std::__swap_bitmap_pos<_AlgPolicy, _RandomAccessIterator>(__first, __lm1, __left_bitset, __right_bitset);
+ __first += (__left_bitset == 0) ? __l_size : 0;
+ __lm1 -= (__right_bitset == 0) ? __r_size : 0;
+}
+
+template <class _AlgPolicy, class _RandomAccessIterator>
+inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(
+ _RandomAccessIterator& __first, _RandomAccessIterator& __lm1, uint64_t& __left_bitset, uint64_t& __right_bitset) {
+ using _Ops = _IterOps<_AlgPolicy>;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ if (__left_bitset) {
+ // Swap within the left side. Need to find set positions in the reverse
+ // order.
+ while (__left_bitset != 0) {
+ difference_type __tz_left = __detail::__block_size - 1 - __libcpp_clz(__left_bitset);
+ __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1;
+ _RandomAccessIterator it = __first + __tz_left;
+ if (it != __lm1) {
+ _Ops::iter_swap(it, __lm1);
+ }
+ --__lm1;
+ }
+ __first = __lm1 + difference_type(1);
+ } else if (__right_bitset) {
+ // Swap within the right side. Need to find set positions in the reverse
+ // order.
+ while (__right_bitset != 0) {
+ difference_type __tz_right = __detail::__block_size - 1 - __libcpp_clz(__right_bitset);
+ __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1;
+ _RandomAccessIterator it = __lm1 - __tz_right;
+ if (it != __first) {
+ _Ops::iter_swap(it, __first);
+ }
+ ++__first;
+ }
+ }
+}
+
+// Partition [__first, __last) using the comparator __comp. *__first has the
+// chosen pivot. Elements that are equivalent are kept to the left of the
+// pivot. Returns the iterator for the pivot and a bool value which is true if
+// the provided range is already sorted, false otherwise. We assume that the
+// length of the range is at least three elements.
+//
+// __bitset_partition uses bitsets for storing outcomes of the comparisons
+// between the pivot and other elements.
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
+__bitset_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
using _Ops = _IterOps<_AlgPolicy>;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ _LIBCPP_ASSERT(__last - __first >= difference_type(3), "");
+
+ _RandomAccessIterator __begin = __first;
+ value_type __pivot(_Ops::__iter_move(__first));
+ // Find the first element greater than the pivot.
+ if (__comp(__pivot, *(__last - difference_type(1)))) {
+ // Not guarded since we know the last element is greater than the pivot.
+ while (!__comp(__pivot, *++__first)) {
+ }
+ } else {
+ while (++__first < __last && !__comp(__pivot, *__first)) {
+ }
+ }
+ // Find the last element less than or equal to the pivot.
+ if (__first < __last) {
+ // It will be always guarded because __introsort will do the median-of-three
+ // before calling this.
+ while (__comp(__pivot, *--__last)) {
+ }
+ }
+ // If the first element greater than the pivot is at or after the
+ // last element less than or equal to the pivot, then we have covered the
+ // entire range without swapping elements. This implies the range is already
+ // partitioned.
+ bool __already_partitioned = __first >= __last;
+ if (!__already_partitioned) {
+ _Ops::iter_swap(__first, __last);
+ ++__first;
+ }
+
+ // In [__first, __last) __last is not inclusive. From now on, it uses last
+ // minus one to be inclusive on both sides.
+ _RandomAccessIterator __lm1 = __last - difference_type(1);
+ uint64_t __left_bitset = 0;
+ uint64_t __right_bitset = 0;
+
+ // Reminder: length = __lm1 - __first + 1.
+ while (__lm1 - __first >= 2 * __detail::__block_size - 1) {
+ // Record the comparison outcomes for the elements currently on the left
+ // side.
+ if (__left_bitset == 0)
+ std::__populate_left_bitset<_Compare>(__first, __comp, __pivot, __left_bitset);
+ // Record the comparison outcomes for the elements currently on the right
+ // side.
+ if (__right_bitset == 0)
+ std::__populate_right_bitset<_Compare>(__lm1, __comp, __pivot, __right_bitset);
+ // Swap the elements recorded to be the candidates for swapping in the
+ // bitsets.
+ std::__swap_bitmap_pos<_AlgPolicy, _RandomAccessIterator>(__first, __lm1, __left_bitset, __right_bitset);
+ // Only advance the iterator if all the elements that need to be moved to
+ // other side were moved.
+ __first += (__left_bitset == 0) ? difference_type(__detail::__block_size) : difference_type(0);
+ __lm1 -= (__right_bitset == 0) ? difference_type(__detail::__block_size) : difference_type(0);
+ }
+ // Now, we have a less-than a block worth of elements on at least one of the
+ // sides.
+ std::__bitset_partition_partial_blocks<_AlgPolicy, _Compare>(
+ __first, __lm1, __comp, __pivot, __left_bitset, __right_bitset);
+ // At least one the bitsets would be empty. For the non-empty one, we need to
+ // properly partition the elements that appear within that bitset.
+ std::__swap_bitmap_pos_within<_AlgPolicy>(__first, __lm1, __left_bitset, __right_bitset);
+
+ // Move the pivot to its correct position.
+ _RandomAccessIterator __pivot_pos = __first - difference_type(1);
+ if (__begin != __pivot_pos) {
+ *__begin = _Ops::__iter_move(__pivot_pos);
+ }
+ *__pivot_pos = std::move(__pivot);
+ return std::make_pair(__pivot_pos, __already_partitioned);
+}
+// Partition [__first, __last) using the comparator __comp. *__first has the
+// chosen pivot. Elements that are equivalent are kept to the right of the
+// pivot. Returns the iterator for the pivot and a bool value which is true if
+// the provided range is already sorted, false otherwise. We assume that the
+// length of the range is at least three elements.
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
+__partition_with_equals_on_right(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ using _Ops = _IterOps<_AlgPolicy>;
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;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _LIBCPP_ASSERT(__last - __first >= difference_type(3), "");
+ _RandomAccessIterator __begin = __first;
+ value_type __pivot(_Ops::__iter_move(__first));
+ // Find the first element greater or equal to the pivot. It will be always
+ // guarded because __introsort will do the median-of-three before calling
+ // this.
+ while (__comp(*++__first, __pivot))
+ ;
+
+ // Find the last element less than the pivot.
+ if (__begin == __first - difference_type(1)) {
+ while (__first < __last && !__comp(*--__last, __pivot))
+ ;
+ } else {
+ // Guarded.
+ while (!__comp(*--__last, __pivot))
+ ;
+ }
+
+ // If the first element greater than or equal to the pivot is at or after the
+ // last element less than the pivot, then we have covered the entire range
+ // without swapping elements. This implies the range is already partitioned.
+ bool __already_partitioned = __first >= __last;
+ // Go through the remaining elements. Swap pairs of elements (one to the
+ // right of the pivot and the other to left of the pivot) that are not on the
+ // correct side of the pivot.
+ while (__first < __last) {
+ _Ops::iter_swap(__first, __last);
+ while (__comp(*++__first, __pivot))
+ ;
+ while (!__comp(*--__last, __pivot))
+ ;
+ }
+ // Move the pivot to its correct position.
+ _RandomAccessIterator __pivot_pos = __first - difference_type(1);
+ if (__begin != __pivot_pos) {
+ *__begin = _Ops::__iter_move(__pivot_pos);
+ }
+ *__pivot_pos = std::move(__pivot);
+ return std::make_pair(__pivot_pos, __already_partitioned);
+}
+
+// Similar to the above function. Elements equivalent to the pivot are put to
+// the left of the pivot. Returns the iterator to the pivot element.
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator
+__partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
+ using _Ops = _IterOps<_AlgPolicy>;
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __begin = __first;
+ value_type __pivot(_Ops::__iter_move(__first));
+ if (__comp(__pivot, *(__last - difference_type(1)))) {
+ // Guarded.
+ while (!__comp(__pivot, *++__first)) {
+ }
+ } else {
+ while (++__first < __last && !__comp(__pivot, *__first)) {
+ }
+ }
+
+ if (__first < __last) {
+ // It will be always guarded because __introsort will do the
+ // median-of-three before calling this.
+ while (__comp(__pivot, *--__last)) {
+ }
+ }
+ while (__first < __last) {
+ _Ops::iter_swap(__first, __last);
+ while (!__comp(__pivot, *++__first))
+ ;
+ while (__comp(__pivot, *--__last))
+ ;
+ }
+ _RandomAccessIterator __pivot_pos = __first - difference_type(1);
+ if (__begin != __pivot_pos) {
+ *__begin = _Ops::__iter_move(__pivot_pos);
+ }
+ *__pivot_pos = std::move(__pivot);
+ return __first;
+}
+
+// The main sorting function. Implements introsort combined with other ideas:
+// - option of using block quick sort for partitioning,
+// - guarded and unguarded insertion sort for small lengths,
+// - Tuckey's ninther technique for computing the pivot,
+// - check on whether partition was not required.
+// The implementation is partly based on Orson Peters' pattern-defeating
+// quicksort, published at: <https://github.com/orlp/pdqsort>.
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, bool _UseBitSetPartition>
+void __introsort(_RandomAccessIterator __first,
+ _RandomAccessIterator __last,
+ _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __depth,
+ bool __leftmost = true) {
+ using _Ops = _IterOps<_AlgPolicy>;
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ using _Comp_ref = __comp_ref_type<_Compare>;
+ // Upper bound for using insertion sort for sorting.
+ _LIBCPP_CONSTEXPR difference_type __limit = 24;
+ // Lower bound for using Tuckey's ninther technique for median computation.
+ _LIBCPP_CONSTEXPR difference_type __ninther_threshold = 128;
while (true) {
- __restart:
difference_type __len = __last - __first;
switch (__len) {
case 0:
@@ -434,7 +793,7 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
return;
case 2:
if (__comp(*--__last, *__first))
- _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+ _Ops::iter_swap(__first, __last);
return;
case 3:
std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
@@ -449,127 +808,60 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
--__last, __comp);
return;
}
- if (__len <= __limit) {
- std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp);
+ // Use insertion sort if the length of the range is below the specified limit.
+ if (__len < __limit) {
+ if (__leftmost) {
+ std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
+ } else {
+ std::__insertion_sort_unguarded<_AlgPolicy, _Compare>(__first, __last, __comp);
+ }
return;
}
- // __len > 5
if (__depth == 0) {
// Fallback to heap sort as Introsort suggests.
std::__partial_sort<_AlgPolicy, _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 = std::__sort5_wrap_policy<_AlgPolicy, _Compare>(
- __first, __first + __delta, __m, __m + __delta, __lm1, __comp);
+ difference_type __half_len = __len / 2;
+ // Use Tuckey's ninther technique or median of 3 for pivot selection
+ // depending on the length of the range being sorted.
+ if (__len > __ninther_threshold) {
+ std::__sort3<_AlgPolicy, _Compare>(__first, __first + __half_len, __last - difference_type(1), __comp);
+ std::__sort3<_AlgPolicy, _Compare>(
+ __first + difference_type(1), __first + (__half_len - 1), __last - difference_type(2), __comp);
+ std::__sort3<_AlgPolicy, _Compare>(
+ __first + difference_type(2), __first + (__half_len + 1), __last - difference_type(3), __comp);
+ std::__sort3<_AlgPolicy, _Compare>(
+ __first + (__half_len - 1), __first + __half_len, __first + (__half_len + 1), __comp);
+ _Ops::iter_swap(__first, __first + __half_len);
} else {
- __delta = __len / 2;
- __m += __delta;
- __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp);
+ std::__sort3<_AlgPolicy, _Compare>(__first + __half_len, __first, __last - difference_type(1), __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)) {
- _Ops::iter_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;
- _Ops::iter_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)) {
- _Ops::iter_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;
- _Ops::iter_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)) {
- _Ops::iter_swap(__i, __m);
- ++__n_swaps;
+ // The elements to the left of the current iterator range are already
+ // sorted. If the current iterator range to be sorted is not the
+ // leftmost part of the entire iterator range and the pivot is same as
+ // the highest element in the range to the left, then we know that all
+ // the elements in the range [first, pivot] would be equal to the pivot,
+ // assuming the equal elements are put on the left side when
+ // partitioned. This also means that we do not need to sort the left
+ // side of the partition.
+ if (!__leftmost && !__comp(*(__first - difference_type(1)), *__first)) {
+ __first = std::__partition_with_equals_on_left<_AlgPolicy, _RandomAccessIterator, _Comp_ref>(
+ __first, __last, _Comp_ref(__comp));
+ continue;
}
+ // Use bitset partition only if asked for.
+ auto __ret =
+ _UseBitSetPartition
+ ? std::__bitset_partition<_AlgPolicy, _RandomAccessIterator, _Compare>(__first, __last, __comp)
+ : std::__partition_with_equals_on_right<_AlgPolicy, _RandomAccessIterator, _Compare>(__first, __last, __comp);
+ _RandomAccessIterator __i = __ret.first;
// [__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) {
+ if (__ret.second) {
using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
_WrappedComp __wrapped_comp(__comp);
bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);
@@ -585,14 +877,11 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
}
}
}
- // sort smaller range with recursive call and larger with tail recursion elimination
- if (__i - __first < __last - __i) {
- std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth);
- __first = ++__i;
- } else {
- std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth);
- __last = __i;
- }
+ // Sort the left partiton recursively and the right partition with tail recursion elimination.
+ std::__introsort<_AlgPolicy, _Compare, _RandomAccessIterator, _UseBitSetPartition>(
+ __first, __i, __comp, __depth, __leftmost);
+ __leftmost = false;
+ __first = ++__i;
}
}
@@ -616,15 +905,22 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
}
template <class _WrappedComp, class _RandomAccessIterator>
-void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
+_LIBCPP_HIDDEN void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __depth_limit = 2 * __log2i(__last - __first);
+ difference_type __depth_limit = 2 * std::__log2i(__last - __first);
using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
using _AlgPolicy = typename _Unwrap::_AlgPolicy;
using _Compare = typename _Unwrap::_Comp;
_Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
- std::__introsort<_AlgPolicy, _Compare>(__first, __last, __comp, __depth_limit);
+ // Only use bitset partitioning for arithmetic types. We should also check
+ // that the default comparator is in use so that we are sure that there are no
+ // branches in the comparator.
+ std::__introsort<_AlgPolicy,
+ _Compare,
+ _RandomAccessIterator,
+ __use_branchless_sort<_Compare, _RandomAccessIterator>::value>(
+ __first, __last, __comp, __depth_limit);
}
template <class _Compare, class _Tp>
@@ -672,11 +968,11 @@ extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long do
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 _AlgPolicy, class _RandomAccessIterator, class _Comp>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
std::__debug_randomize_range<_AlgPolicy>(__first, __last);
- using _Comp_ref = typename __comp_ref_type<_Comp>::type;
+ using _Comp_ref = __comp_ref_type<_Comp>;
if (__libcpp_is_constant_evaluated()) {
std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);
@@ -689,13 +985,13 @@ void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
}
template <class _RandomAccessIterator, class _Comp>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
diff --git a/libcxx/include/__algorithm/sort_heap.h b/libcxx/include/__algorithm/sort_heap.h
index b9f0b2c9690d..8249407b5509 100644
--- a/libcxx/include/__algorithm/sort_heap.h
+++ b/libcxx/include/__algorithm/sort_heap.h
@@ -25,18 +25,17 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
- using _CompRef = typename __comp_ref_type<_Compare>::type;
- _CompRef __comp_ref = __comp;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
+ __comp_ref_type<_Compare> __comp_ref = __comp;
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
- std::__pop_heap<_AlgPolicy, _CompRef>(__first, __last, __comp_ref, __n);
+ std::__pop_heap<_AlgPolicy>(__first, __last, __comp_ref, __n);
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
@@ -45,7 +44,7 @@ void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
}
template <class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
std::sort_heap(std::move(__first), std::move(__last),
__less<typename iterator_traits<_RandomAccessIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/stable_partition.h b/libcxx/include/__algorithm/stable_partition.h
index e5ad48b2ed51..a49de6dbb0ef 100644
--- a/libcxx/include/__algorithm/stable_partition.h
+++ b/libcxx/include/__algorithm/stable_partition.h
@@ -15,7 +15,12 @@
#include <__iterator/advance.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
-#include <memory>
+#include <__memory/destruct_n.h>
+#include <__memory/temporary_buffer.h>
+#include <__memory/unique_ptr.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <new>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -25,7 +30,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
-_ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _ForwardIterator
__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
_Distance __len, _Pair __p, forward_iterator_tag __fit)
{
@@ -108,13 +113,13 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first;
// TTTTTTTTFFFFFFFFFF
// |
}
template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
-_ForwardIterator
+_LIBCPP_HIDE_FROM_ABI _ForwardIterator
__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
forward_iterator_tag)
{
@@ -253,13 +258,13 @@ __first_half_done:
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first;
// TTTTTTTTFFFFFFFFFF
// |
}
template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
-_BidirectionalIterator
+_LIBCPP_HIDE_FROM_ABI _BidirectionalIterator
__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
bidirectional_iterator_tag)
{
@@ -305,7 +310,7 @@ template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Ite
_LIBCPP_HIDE_FROM_ABI
_ForwardIterator __stable_partition(
_ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {
- return std::__stable_partition_impl<_AlgPolicy, __uncvref_t<_Predicate>&>(
+ return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>(
std::move(__first), std::move(__last), __pred, __iter_category);
}
diff --git a/libcxx/include/__algorithm/stable_sort.h b/libcxx/include/__algorithm/stable_sort.h
index 6122758bdefe..8e70978ab61c 100644
--- a/libcxx/include/__algorithm/stable_sort.h
+++ b/libcxx/include/__algorithm/stable_sort.h
@@ -16,8 +16,12 @@
#include <__algorithm/sort.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__memory/destruct_n.h>
+#include <__memory/temporary_buffer.h>
+#include <__memory/unique_ptr.h>
#include <__utility/move.h>
-#include <memory>
+#include <__utility/pair.h>
+#include <new>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -27,7 +31,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
-void
+_LIBCPP_HIDE_FROM_ABI void
__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
@@ -69,7 +73,7 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-void
+_LIBCPP_HIDE_FROM_ABI void
__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
@@ -203,7 +207,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
}
std::__stable_sort<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
std::__stable_sort<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
- std::__inplace_merge<_AlgPolicy, _Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+ std::__inplace_merge<_AlgPolicy>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
}
template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
@@ -223,8 +227,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
__h.reset(__buf.first);
}
- using _Comp_ref = typename __comp_ref_type<_Compare>::type;
- std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
+ std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);
}
template <class _RandomAccessIterator, class _Compare>
diff --git a/libcxx/include/__algorithm/swap_ranges.h b/libcxx/include/__algorithm/swap_ranges.h
index 0422265bb4be..5ce5ed8c8845 100644
--- a/libcxx/include/__algorithm/swap_ranges.h
+++ b/libcxx/include/__algorithm/swap_ranges.h
@@ -9,8 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H
#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
+#include <__algorithm/iterator_operations.h>
#include <__config>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,12 +20,39 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// 2+2 iterators: the shorter size will be used.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+pair<_ForwardIterator1, _ForwardIterator2>
+__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+
+ return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
+}
+
+// 2+1 iterators: size2 >= size1.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+pair<_ForwardIterator1, _ForwardIterator2>
+__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
+ while (__first1 != __last1) {
+ _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+
+ return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
+}
+
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
- for (; __first1 != __last1; ++__first1, (void)++__first2)
- swap(*__first1, *__first2);
- return __first2;
+ return std::__swap_ranges<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2)).second;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/transform.h b/libcxx/include/__algorithm/transform.h
index f9db806f5b94..4722c154cfff 100644
--- a/libcxx/include/__algorithm/transform.h
+++ b/libcxx/include/__algorithm/transform.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
{
@@ -28,7 +28,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_OutputIterator __result, _BinaryOperation __binary_op)
diff --git a/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h b/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h
new file mode 100644
index 000000000000..1e86074b3dbd
--- /dev/null
+++ b/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.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_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
+#define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Range versions of random algorithms (e.g. `std::shuffle`) are less constrained than their classic counterparts.
+// Range algorithms only require the given generator to satisfy the `std::uniform_random_bit_generator` concept.
+// Classic algorithms require the given generator to meet the uniform random bit generator requirements; these
+// requirements include satisfying `std::uniform_random_bit_generator` and add a requirement for the generator to
+// provide a nested `result_type` typedef (see `[rand.req.urng]`).
+//
+// To be able to reuse classic implementations, make the given generator meet the classic requirements by wrapping
+// it into an adaptor type that forwards all of its interface and adds the required typedef.
+template <class _Gen>
+class _ClassicGenAdaptor {
+private:
+ // The generator is not required to be copyable or movable, so it has to be stored as a reference.
+ _Gen& __gen_;
+
+public:
+ using result_type = invoke_result_t<_Gen&>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto min() { return __remove_cvref_t<_Gen>::min(); }
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto max() { return __remove_cvref_t<_Gen>::max(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen_(__g) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()() const { return __gen_(); }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
diff --git a/libcxx/include/__algorithm/unique.h b/libcxx/include/__algorithm/unique.h
index 264d727d93c8..1717a00c8a93 100644
--- a/libcxx/include/__algorithm/unique.h
+++ b/libcxx/include/__algorithm/unique.h
@@ -11,9 +11,11 @@
#include <__algorithm/adjacent_find.h>
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,32 +25,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// unique
+template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
+__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ __first = std::__adjacent_find(__first, __last, __pred);
+ if (__first != __last) {
+ // ... a a ? ...
+ // f i
+ _Iter __i = __first;
+ for (++__i; ++__i != __last;)
+ if (!__pred(*__first, *__i))
+ *++__first = _IterOps<_AlgPolicy>::__iter_move(__i);
+ ++__first;
+ return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i));
+ }
+ return std::pair<_Iter, _Iter>(__first, __first);
+}
+
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;
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
+ return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).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_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last) {
+ return std::unique(__first, __last, __equal_to());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/unique_copy.h b/libcxx/include/__algorithm/unique_copy.h
index f58517749f51..81fcd50f011d 100644
--- a/libcxx/include/__algorithm/unique_copy.h
+++ b/libcxx/include/__algorithm/unique_copy.h
@@ -10,8 +10,14 @@
#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_same.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -19,88 +25,98 @@
_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);
+namespace __unique_copy_tags {
+
+struct __reread_from_input_tag {};
+struct __reread_from_output_tag {};
+struct __read_from_tmp_value_tag {};
+
+} // namespace __unique_copy_tags
+
+template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__read_from_tmp_value_tag) {
+ if (__first != __last) {
+ typename _IterOps<_AlgPolicy>::template __value_type<_InputIterator> __t(*__first);
+ *__result = __t;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(__t, *__first)) {
+ __t = *__first;
*__result = __t;
++__result;
- while (++__first != __last)
- {
- if (!__pred(__t, *__first))
- {
- __t = *__first;
- *__result = __t;
- ++__result;
- }
- }
+ }
}
- return __result;
+ }
+ return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__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;
+template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
+__unique_copy(_ForwardIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_input_tag) {
+ if (__first != __last) {
+ _ForwardIterator __i = __first;
+ *__result = *__i;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(*__i, *__first)) {
+ *__result = *__first;
++__result;
- while (++__first != __last)
- {
- if (!__pred(*__i, *__first))
- {
- *__result = *__first;
- ++__result;
- __i = __first;
- }
- }
+ __i = __first;
+ }
}
- return __result;
+ }
+ return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__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 _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _InputAndOutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_output_tag) {
+ if (__first != __last) {
+ *__result = *__first;
+ while (++__first != __last)
+ if (!__pred(*__result, *__first))
+ *++__result = *__first;
+ ++__result;
+ }
+ return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__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());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
+ using __algo_tag = __conditional_t<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
+ __unique_copy_tags::__reread_from_input_tag,
+ __conditional_t<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
+ is_same< typename iterator_traits<_InputIterator>::value_type,
+ typename iterator_traits<_OutputIterator>::value_type>::value,
+ __unique_copy_tags::__reread_from_output_tag,
+ __unique_copy_tags::__read_from_tmp_value_tag> >;
+ return std::__unique_copy<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
+ .second;
}
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>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to());
}
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h
index fa9a8fbf2dde..0f661e10a74d 100644
--- a/libcxx/include/__algorithm/unwrap_iter.h
+++ b/libcxx/include/__algorithm/unwrap_iter.h
@@ -12,8 +12,10 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__utility/declval.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -57,7 +59,7 @@ struct __unwrap_iter_impl<_Iter, true> {
template<class _Iter,
class _Impl = __unwrap_iter_impl<_Iter>,
__enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {
return _Impl::__unwrap(__i);
}
diff --git a/libcxx/include/__algorithm/unwrap_range.h b/libcxx/include/__algorithm/unwrap_range.h
new file mode 100644
index 000000000000..2c5d23e69f10
--- /dev/null
+++ b/libcxx/include/__algorithm/unwrap_range.h
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
+#define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
+
+#include <__algorithm/unwrap_iter.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/next.h>
+#include <__utility/declval.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
+
+// __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types.
+// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
+// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.
+
+#if _LIBCPP_STD_VER > 17
+template <class _Iter, class _Sent>
+struct __unwrap_range_impl {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ auto __last = ranges::next(__first, __sent);
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
+ return pair{std::move(__first), std::move(__last)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
+ requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
+ {
+ return __iter;
+ }
+};
+
+template <class _Iter>
+struct __unwrap_range_impl<_Iter, _Iter> {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+};
+
+template <class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
+ return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
+}
+
+template <
+ class _Sent,
+ class _Iter,
+ class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))>
+_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
+}
+#else // _LIBCPP_STD_VER > 17
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) {
+ return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
+}
+
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+}
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
diff --git a/libcxx/include/__algorithm/upper_bound.h b/libcxx/include/__algorithm/upper_bound.h
index 1045380bc84e..96552ce1f8ac 100644
--- a/libcxx/include/__algorithm/upper_bound.h
+++ b/libcxx/include/__algorithm/upper_bound.h
@@ -28,7 +28,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
while (__len != 0) {
@@ -45,7 +45,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
}
template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
static_assert(is_copy_constructible<_ForwardIterator>::value,
"Iterator has to be copy constructible");
@@ -54,7 +54,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
}
template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
return std::upper_bound(
std::move(__first),
diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index 82db2cf052b5..9c0cd1b1192a 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -10,20 +10,16 @@
#ifndef _LIBCPP___ASSERT
#define _LIBCPP___ASSERT
-#include <__availability>
#include <__config>
+#include <__verbose_abort>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-// This is for backwards compatibility with code that might have been enabling
-// assertions through the Debug mode previously.
-// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
+// TODO: Remove in LLVM 17.
#if defined(_LIBCPP_DEBUG)
-# ifndef _LIBCPP_ENABLE_ASSERTIONS
-# define _LIBCPP_ENABLE_ASSERTIONS 1
-# endif
+# error "Defining _LIBCPP_DEBUG is not supported anymore. Please use _LIBCPP_ENABLE_DEBUG_MODE instead."
#endif
// Automatically enable assertions when the debug mode is enabled.
@@ -45,7 +41,7 @@
# define _LIBCPP_ASSERT(expression, message) \
(__builtin_expect(static_cast<bool>(expression), 1) ? \
(void)0 : \
- ::std::__libcpp_assertion_handler("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
+ _LIBCPP_VERBOSE_ABORT("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
# define _LIBCPP_ASSERT(expression, message) \
(_LIBCPP_DIAGNOSTIC_PUSH \
@@ -56,11 +52,4 @@
# define _LIBCPP_ASSERT(expression, message) ((void)0)
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ASSERTION_HANDLER _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
-void __libcpp_assertion_handler(const char *__format, ...);
-
-_LIBCPP_END_NAMESPACE_STD
-
#endif // _LIBCPP___ASSERT
diff --git a/libcxx/include/__availability b/libcxx/include/__availability
index f9d824509f3d..6dfca3fa8b1a 100644
--- a/libcxx/include/__availability
+++ b/libcxx/include/__availability
@@ -156,22 +156,10 @@
# define _LIBCPP_AVAILABILITY_FORMAT
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
- // This controls whether the std::__libcpp_assertion_handler default
- // assertion handler is provided by the library.
- //
- // Note that when users provide their own custom assertion handler,
- // it doesn't matter whether the dylib provides a default handler,
- // and the availability markup can actually give a false positive
- // diagnostic (it will think that no handler is provided, when in
- // reality the user has provided their own).
- //
- // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED
- // to the compiler to tell the library to ignore the fact that the
- // default handler isn't available on their deployment target. Note that
- // defining this macro but failing to define a custom assertion handler
- // will lead to a load-time error on back-deployment targets, so it
- // should be avoided.
-# define _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER
+ // This controls whether the library claims to provide a default verbose
+ // termination function, and consequently whether the headers will try
+ // to use it when the mechanism isn't overriden at compile-time.
+// # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
#elif defined(__APPLE__)
@@ -272,8 +260,8 @@
__attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
-# define _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER \
- __attribute__((unavailable))
+# define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
+
#else
// ...New vendors can add availability markup here...
@@ -297,14 +285,4 @@
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
-// Define the special assertion handler availability attribute, which can be silenced by
-// users if they provide their own custom assertion handler. The rest of the code should
-// not use the *_DEFAULT_* macro directly, since that would make it ignore the fact that
-// the user provided a custom handler.
-#if defined(_LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED)
-# define _LIBCPP_AVAILABILITY_ASSERTION_HANDLER /* nothing */
-#else
-# define _LIBCPP_AVAILABILITY_ASSERTION_HANDLER _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER
-#endif
-
#endif // _LIBCPP___AVAILABILITY
diff --git a/libcxx/include/__bit/bit_cast.h b/libcxx/include/__bit/bit_cast.h
index 831207671ec9..2ca4120c7630 100644
--- a/libcxx/include/__bit/bit_cast.h
+++ b/libcxx/include/__bit/bit_cast.h
@@ -11,7 +11,7 @@
#define _LIBCPP___BIT_BIT_CAST_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_trivially_copyable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__bit/bit_ceil.h b/libcxx/include/__bit/bit_ceil.h
new file mode 100644
index 000000000000..a558d6194270
--- /dev/null
+++ b/libcxx/include/__bit/bit_ceil.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___BIT_BIT_CEIL_H
+#define _LIBCPP___BIT_BIT_CEIL_H
+
+#include <__assert>
+#include <__bit/countl.h>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
+ if (__t < 2)
+ return 1;
+ const unsigned __n = numeric_limits<_Tp>::digits - std::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);
+ }
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BIT_CEIL_H
diff --git a/libcxx/include/__bit/bit_floor.h b/libcxx/include/__bit/bit_floor.h
new file mode 100644
index 000000000000..b2e38092f2d7
--- /dev/null
+++ b/libcxx/include/__bit/bit_floor.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___BIT_BIT_FLOOR_H
+#define _LIBCPP___BIT_BIT_FLOOR_H
+
+#include <__bit/bit_log2.h>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
+ return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BIT_FLOOR_H
diff --git a/libcxx/include/__bit/bit_log2.h b/libcxx/include/__bit/bit_log2.h
new file mode 100644
index 000000000000..62936f678686
--- /dev/null
+++ b/libcxx/include/__bit/bit_log2.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___BIT_BIT_LOG2_H
+#define _LIBCPP___BIT_BIT_LOG2_H
+
+#include <__bit/countl.h>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
+ return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BIT_LOG2_H
diff --git a/libcxx/include/__bit/bit_width.h b/libcxx/include/__bit/bit_width.h
new file mode 100644
index 000000000000..4381f227f5e5
--- /dev/null
+++ b/libcxx/include/__bit/bit_width.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___BIT_BIT_WIDTH_H
+#define _LIBCPP___BIT_BIT_WIDTH_H
+
+#include <__bit/bit_log2.h>
+#include <__concepts/arithmetic.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
+ return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP___BIT_BIT_WIDTH_H
diff --git a/libcxx/include/__bit/blsr.h b/libcxx/include/__bit/blsr.h
new file mode 100644
index 000000000000..de991e9adb3b
--- /dev/null
+++ b/libcxx/include/__bit/blsr.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___BIT_BLSR_H
+#define _LIBCPP___BIT_BLSR_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned __libcpp_blsr(unsigned __x) _NOEXCEPT {
+ return __x ^ (__x & -__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned long __libcpp_blsr(unsigned long __x) _NOEXCEPT {
+ return __x ^ (__x & -__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned long long __libcpp_blsr(unsigned long long __x) _NOEXCEPT {
+ return __x ^ (__x & -__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_BLSR_H
diff --git a/libcxx/include/__bit/countl.h b/libcxx/include/__bit/countl.h
new file mode 100644
index 000000000000..86eaee0c1b3b
--- /dev/null
+++ b/libcxx/include/__bit/countl.h
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_COUNTL_H
+#define _LIBCPP___BIT_COUNTL_H
+
+#include <__bit/rotate.h>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__type_traits/is_unsigned_integer.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
+
+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); }
+
+# ifndef _LIBCPP_HAS_NO_INT128
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
+ // The function is written in this form due to C++ constexpr limitations.
+ // The algorithm:
+ // - Test whether any bit in the high 64-bits is set
+ // - No bits set:
+ // - The high 64-bits contain 64 leading zeros,
+ // - Add the result of the low 64-bits.
+ // - Any bits set:
+ // - The number of leading zeros of the input is the number of leading
+ // zeros in the high 64-bits.
+ return ((__x >> 64) == 0)
+ ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
+ : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
+}
+# endif // _LIBCPP_HAS_NO_INT128
+
+template<class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+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 std::__libcpp_clz(static_cast<unsigned int>(__t))
+ - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return std::__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 std::__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 = std::__rotr(__t, __ulldigits);
+ if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
+ break;
+ __ret += __iter;
+ }
+ return __ret + __iter;
+ }
+}
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
+ return std::__countl_zero(__t);
+}
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
+ return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BIT_COUNTL_H
diff --git a/libcxx/include/__bit/countr.h b/libcxx/include/__bit/countr.h
new file mode 100644
index 000000000000..d3ca5b6c94f1
--- /dev/null
+++ b/libcxx/include/__bit/countr.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___BIT_COUNTR_H
+#define _LIBCPP___BIT_COUNTR_H
+
+#include <__bit/rotate.h>
+#include <__concepts/arithmetic.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
+
+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); }
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return std::__libcpp_ctz(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return std::__libcpp_ctz(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return std::__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 + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
+ }
+}
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
+ return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BIT_COUNTR_H
diff --git a/libcxx/include/__bit/endian.h b/libcxx/include/__bit/endian.h
new file mode 100644
index 000000000000..52635f2d2495
--- /dev/null
+++ b/libcxx/include/__bit/endian.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___BIT_ENDIAN_H
+#define _LIBCPP___BIT_ENDIAN_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP___BIT_ENDIAN_H
diff --git a/libcxx/include/__bit/has_single_bit.h b/libcxx/include/__bit/has_single_bit.h
new file mode 100644
index 000000000000..b89f5995b32d
--- /dev/null
+++ b/libcxx/include/__bit/has_single_bit.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___BIT_HAS_SINGLE_BIT_H
+#define _LIBCPP___BIT_HAS_SINGLE_BIT_H
+
+#include <__concepts/arithmetic.h>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
+ return __t != 0 && (((__t & (__t - 1)) == 0));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BIT_HAS_SINGLE_BIT_H
diff --git a/libcxx/include/__bit/popcount.h b/libcxx/include/__bit/popcount.h
new file mode 100644
index 000000000000..33b94cff7122
--- /dev/null
+++ b/libcxx/include/__bit/popcount.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___BIT_POPCOUNT_H
+#define _LIBCPP___BIT_POPCOUNT_H
+
+#include <__bit/rotate.h>
+#include <__concepts/arithmetic.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
+
+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); }
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return std::__libcpp_popcount(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return std::__libcpp_popcount(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
+ else {
+ int __ret = 0;
+ while (__t != 0) {
+ __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
+ __t >>= numeric_limits<unsigned long long>::digits;
+ }
+ return __ret;
+ }
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___BIT_POPCOUNT_H
diff --git a/libcxx/include/__bit/rotate.h b/libcxx/include/__bit/rotate.h
new file mode 100644
index 000000000000..5aa7518b3c57
--- /dev/null
+++ b/libcxx/include/__bit/rotate.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___BIT_ROTATE_H
+#define _LIBCPP___BIT_ROTATE_H
+
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__type_traits/is_unsigned_integer.h>
+#include <limits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+_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)));
+}
+
+#if _LIBCPP_STD_VER >= 20
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
+ const unsigned int __dig = numeric_limits<_Tp>::digits;
+ if ((__cnt % __dig) == 0)
+ return __t;
+ return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
+}
+
+template <__libcpp_unsigned_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
+ return std::__rotr(__t, __cnt);
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___BIT_ROTATE_H
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index f54cb6c16f48..26657491393d 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -10,10 +10,14 @@
#ifndef _LIBCPP___BIT_REFERENCE
#define _LIBCPP___BIT_REFERENCE
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
#include <__algorithm/min.h>
-#include <__bits>
+#include <__bit/countr.h>
+#include <__bit/popcount.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <cstring>
#include <type_traits>
@@ -51,15 +55,17 @@ class __bit_reference
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>;
public:
- _LIBCPP_INLINE_VISIBILITY
+ using __container = typename _Cp::__self;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_reference(const __bit_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
- _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator ~() const _NOEXCEPT
{return !static_cast<bool>(*this);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_reference& operator=(bool __x) _NOEXCEPT
{
if (__x)
@@ -70,7 +76,7 @@ public:
}
#if _LIBCPP_STD_VER > 20
- _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
+ _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
if (__x)
*__seg_ |= __mask_;
else
@@ -79,15 +85,15 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__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_)));}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+ {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
};
@@ -98,7 +104,7 @@ class __bit_reference<_Cp, false>
};
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -108,7 +114,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
}
template <class _Cp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
{
@@ -118,7 +124,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
{
@@ -128,7 +134,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -152,15 +158,15 @@ public:
_LIBCPP_INLINE_VISIBILITY
__bit_const_reference(const __bit_const_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__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_)));}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+ {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
@@ -173,12 +179,12 @@ private:
// find
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -209,7 +215,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>
__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
@@ -248,7 +254,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_iterator<_Cp, _IsConst>
find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
{
@@ -260,7 +266,7 @@ find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
// count
template <class _Cp, bool _IsConst>
-typename __bit_iterator<_Cp, _IsConst>::difference_type
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 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;
@@ -291,7 +297,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst>
-typename __bit_iterator<_Cp, _IsConst>::difference_type
+_LIBCPP_HIDE_FROM_ABI 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;
@@ -334,7 +340,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
// fill_n
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -352,7 +358,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
+ std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -364,7 +370,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -382,7 +388,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+ // __storage_type is always an unsigned type, so -1 sets all bits
+ std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -394,7 +401,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
{
@@ -410,7 +417,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
// fill
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
{
@@ -420,7 +427,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
// copy
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -449,9 +456,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
// __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));
+ std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
__result.__seg_ += __nw;
// do last word
@@ -469,14 +474,14 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -547,7 +552,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_iterator<_Cp, false>
copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -559,7 +564,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
// copy_backward
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -590,9 +595,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
__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));
+ std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
// do last word
if (__n > 0)
@@ -608,7 +611,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -694,7 +697,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_iterator<_Cp, false>
copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -726,7 +729,7 @@ move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCons
// swap_ranges
template <class __C1, class __C2>
-__bit_iterator<__C2, false>
+_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
__bit_iterator<__C2, false> __result)
{
@@ -776,7 +779,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,
}
template <class __C1, class __C2>
-__bit_iterator<__C2, false>
+_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
__bit_iterator<__C2, false> __result)
{
@@ -901,14 +904,19 @@ struct __bit_array
difference_type __size_;
__storage_type __word_[_Np];
- _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_array(difference_type __s) : __size_(__s) {
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
+ std::__construct_at(__word_ + __i, 0);
+ }
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
}
- _LIBCPP_INLINE_VISIBILITY iterator end()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
static_cast<unsigned>(__size_ % __bits_per_word));
@@ -916,7 +924,7 @@ struct __bit_array
};
template <class _Cp>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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;
@@ -967,14 +975,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
// equal
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1049,14 +1057,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
}
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1092,7 +1100,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
}
template <class _Cp, bool _IC1, bool _IC2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
{
@@ -1110,23 +1118,23 @@ public:
typedef bool value_type;
typedef __bit_iterator pointer;
#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
- typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
+ typedef __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> > reference;
#else
- using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type;
+ using reference = __conditional_t<_IsConst, bool, __bit_reference<_Cp> >;
#endif
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;
+ typedef __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>
+ __storage_pointer;
static const unsigned __bits_per_word = _Cp::__bits_per_word;
__storage_pointer __seg_;
unsigned __ctz_;
public:
- _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __seg_(nullptr), __ctz_(0)
#endif
@@ -1137,7 +1145,7 @@ public:
// When _IsConst=true, this is a converting constructor;
// the copy and move constructors are implicitly generated
// and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
@@ -1146,19 +1154,19 @@ public:
// the implicit generation of a defaulted one is deprecated.
// When _IsConst=true, the assignment operators are
// implicitly generated and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__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 typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
- ::type(__seg_, __storage_type(1) << __ctz_);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
+ return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(
+ __seg_, __storage_type(1) << __ctz_);
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator++()
{
if (__ctz_ != __bits_per_word-1)
++__ctz_;
@@ -1170,14 +1178,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator++(int)
{
__bit_iterator __tmp = *this;
++(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator--()
{
if (__ctz_ != 0)
--__ctz_;
@@ -1189,14 +1197,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator--(int)
{
__bit_iterator __tmp = *this;
--(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator+=(difference_type __n)
{
if (__n >= 0)
__seg_ += (__n + __ctz_) / __bits_per_word;
@@ -1208,54 +1216,54 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator-=(difference_type __n)
{
return *this += -__n;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const
{
__bit_iterator __t(*this);
__t -= __n;
return __t;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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 _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {return *(*this + __n);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x < __y);}
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
: __seg_(__s), __ctz_(__ctz) {}
@@ -1265,26 +1273,44 @@ private:
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 _Dp>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>);
@@ -1294,23 +1320,34 @@ private:
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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend bool equal(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
__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);
diff --git a/libcxx/include/__bits b/libcxx/include/__bits
deleted file mode 100644
index 92ef5c0a7b49..000000000000
--- a/libcxx/include/__bits
+++ /dev/null
@@ -1,162 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___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); }
-
-# ifndef _LIBCPP_HAS_NO_INT128
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
- // The function is written in this form due to C++ constexpr limitations.
- // The algorithm:
- // - Test whether any bit in the high 64-bits is set
- // - No bits set:
- // - The high 64-bits contain 64 leading zeros,
- // - Add the result of the low 64-bits.
- // - Any bits set:
- // - The number of leading zeros of the input is the number of leading
- // zeros in the high 64-bits.
- return ((__x >> 64) == 0)
- ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
- : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
-}
-# endif
-
-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 __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, "");
- return __popcnt64(__x);
-}
-
-#endif // _LIBCPP_COMPILER_MSVC
-
-_LIBCPP_END_NAMESPACE_STD
-
-_LIBCPP_POP_MACROS
-
-#endif // _LIBCPP___BITS
diff --git a/libcxx/include/__bsd_locale_fallbacks.h b/libcxx/include/__bsd_locale_fallbacks.h
index 3d5b78574480..9abd7e7e5ff4 100644
--- a/libcxx/include/__bsd_locale_fallbacks.h
+++ b/libcxx/include/__bsd_locale_fallbacks.h
@@ -13,7 +13,6 @@
#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H
#define _LIBCPP___BSD_LOCALE_FALLBACKS_H
-#include <memory>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/libcxx/include/__charconv/chars_format.h b/libcxx/include/__charconv/chars_format.h
index 0875079e6c7a..695bd873189c 100644
--- a/libcxx/include/__charconv/chars_format.h
+++ b/libcxx/include/__charconv/chars_format.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
enum class _LIBCPP_ENUM_VIS chars_format
{
@@ -52,25 +52,25 @@ operator^(chars_format __x, chars_format __y) {
_VSTD::__to_underlying(__y));
}
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
operator&=(chars_format& __x, chars_format __y) {
__x = __x & __y;
return __x;
}
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
operator|=(chars_format& __x, chars_format __y) {
__x = __x | __y;
return __x;
}
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
operator^=(chars_format& __x, chars_format __y) {
__x = __x ^ __y;
return __x;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__charconv/from_chars_result.h b/libcxx/include/__charconv/from_chars_result.h
index 2cc3c11ef64f..05ffe1485cae 100644
--- a/libcxx/include/__charconv/from_chars_result.h
+++ b/libcxx/include/__charconv/from_chars_result.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
struct _LIBCPP_TYPE_VIS from_chars_result
{
@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result
# endif
};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__charconv/tables.h b/libcxx/include/__charconv/tables.h
index 83f39e6fd2ef..9b82440348be 100644
--- a/libcxx/include/__charconv/tables.h
+++ b/libcxx/include/__charconv/tables.h
@@ -19,38 +19,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
namespace __itoa {
-/// Contains the charconv helper tables.
-///
-/// In C++17 these could be inline constexpr variable, but libc++ supports
-/// charconv for integrals in C++11 mode.
-template <class = void>
-struct __table {
- static const char __base_2_lut[64];
- static const char __base_8_lut[128];
- static const char __base_16_lut[512];
-
- static const uint32_t __pow10_32[10];
- static const uint64_t __pow10_64[20];
-# ifndef _LIBCPP_HAS_NO_INT128
- // TODO FMT Reduce the number of entries in this table.
- static const __uint128_t __pow10_128[40];
- static const int __pow10_128_offset = 0;
-# endif
- static const char __digits_base_10[200];
-};
-
-template <class _Tp>
-const char __table<_Tp>::__base_2_lut[64] = {
+inline constexpr char __base_2_lut[64] = {
'0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
'0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
'1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
-template <class _Tp>
-const char __table<_Tp>::__base_8_lut[128] = {
+inline constexpr char __base_8_lut[128] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
'1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
'2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
@@ -58,8 +36,7 @@ const char __table<_Tp>::__base_8_lut[128] = {
'5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
'6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
-template <class _Tp>
-const char __table<_Tp>::__base_16_lut[512] = {
+inline constexpr char __base_16_lut[512] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
'1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
@@ -84,13 +61,11 @@ const char __table<_Tp>::__base_16_lut[512] = {
'1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
'f', 'd', 'f', 'e', 'f', 'f'};
-template <class _Tp>
-const uint32_t __table<_Tp>::__pow10_32[10] = {
+inline constexpr uint32_t __pow10_32[10] = {
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 <class _Tp>
-const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
+inline constexpr uint64_t __pow10_64[20] = {UINT64_C(0),
UINT64_C(10),
UINT64_C(100),
UINT64_C(1000),
@@ -112,8 +87,8 @@ const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
UINT64_C(10000000000000000000)};
# ifndef _LIBCPP_HAS_NO_INT128
-template <class _Tp>
-const __uint128_t __table<_Tp>::__pow10_128[40] = {
+inline constexpr int __pow10_128_offset = 0;
+inline constexpr __uint128_t __pow10_128[40] = {
UINT64_C(0),
UINT64_C(10),
UINT64_C(100),
@@ -156,8 +131,7 @@ const __uint128_t __table<_Tp>::__pow10_128[40] = {
(__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
# endif
-template <class _Tp>
-const char __table<_Tp>::__digits_base_10[200] = {
+inline constexpr char __digits_base_10[200] = {
// clang-format off
'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',
@@ -173,7 +147,7 @@ const char __table<_Tp>::__digits_base_10[200] = {
} // namespace __itoa
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__charconv/to_chars_base_10.h b/libcxx/include/__charconv/to_chars_base_10.h
index d25deffc592f..fc7fb76e3e98 100644
--- a/libcxx/include/__charconv/to_chars_base_10.h
+++ b/libcxx/include/__charconv/to_chars_base_10.h
@@ -25,54 +25,54 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
namespace __itoa {
-_LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
*__first = '0' + static_cast<char>(__value);
return __first + 1;
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
- return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first);
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
+ return std::copy_n(&__digits_base_10[__value * 2], 2, __first);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
}
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
static_cast<uint32_t>(__value % 100000000));
}
-_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
if (__value < 1000000) {
if (__value < 10000) {
if (__value < 100) {
@@ -107,7 +107,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value
return __itoa::__append10(__first, __value);
}
-_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
if (__value <= UINT32_MAX)
return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
@@ -129,12 +129,12 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __valu
/// \note The lookup table contains a partial set of exponents limiting the
/// range that can be used. However the range is sufficient for
/// \ref __base_10_u128.
-_LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
- _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds");
- return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset];
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
+ _LIBCPP_ASSERT(__exp >= __pow10_128_offset, "Index out of bounds");
+ return __pow10_128[__exp - __pow10_128_offset];
}
-_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
_LIBCPP_ASSERT(
__value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
@@ -176,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __
# endif
} // namespace __itoa
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__charconv/to_chars_result.h b/libcxx/include/__charconv/to_chars_result.h
index b4bc6ac2635b..2eb4098dfc42 100644
--- a/libcxx/include/__charconv/to_chars_result.h
+++ b/libcxx/include/__charconv/to_chars_result.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
struct _LIBCPP_TYPE_VIS to_chars_result
{
@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result
# endif
};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__chrono/convert_to_timespec.h b/libcxx/include/__chrono/convert_to_timespec.h
index e8631d135fee..fab07f2567d4 100644
--- a/libcxx/include/__chrono/convert_to_timespec.h
+++ b/libcxx/include/__chrono/convert_to_timespec.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
#define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
diff --git a/libcxx/include/__chrono/convert_to_tm.h b/libcxx/include/__chrono/convert_to_tm.h
new file mode 100644
index 000000000000..36846b3f7140
--- /dev/null
+++ b/libcxx/include/__chrono/convert_to_tm.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___CHRONO_CONVERT_TO_TM_H
+#define _LIBCPP___CHRONO_CONVERT_TO_TM_H
+
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/hh_mm_ss.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
+#include <__chrono/statically_widen.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__memory/addressof.h>
+#include <cstdint>
+#include <ctime>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+// Conerts a chrono date and weekday to a given _Tm type.
+//
+// This is an implementation detail for the function
+// template <class _Tm, class _ChronoT>
+// _Tm __convert_to_tm(const _ChronoT& __value)
+//
+// This manually converts the two values to the proper type. It is possible to
+// convert from sys_days to time_t and then to _Tm. But this leads to the Y2K
+// bug when time_t is a 32-bit signed integer. Chrono considers years beyond
+// the year 2038 valid, so instead do the transformation manually.
+template <class _Tm, class _Date>
+ requires(same_as<_Date, chrono::year_month_day> || same_as<_Date, chrono::year_month_day_last>)
+_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _Date& __date, chrono::weekday __weekday) {
+ _Tm __result = {};
+# ifdef __GLIBC__
+ __result.tm_zone = "UTC";
+# endif
+ __result.tm_year = static_cast<int>(__date.year()) - 1900;
+ __result.tm_mon = static_cast<unsigned>(__date.month()) - 1;
+ __result.tm_mday = static_cast<unsigned>(__date.day());
+ __result.tm_wday = static_cast<unsigned>(__weekday.c_encoding());
+ __result.tm_yday =
+ (static_cast<chrono::sys_days>(__date) -
+ static_cast<chrono::sys_days>(chrono::year_month_day{__date.year(), chrono::January, chrono::day{1}}))
+ .count();
+
+ return __result;
+}
+
+// Convert a chrono (calendar) time point, or dururation to the given _Tm type,
+// which must have the same properties as std::tm.
+template <class _Tm, class _ChronoT>
+_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
+ _Tm __result = {};
+# ifdef __GLIBC__
+ __result.tm_zone = "UTC";
+# endif
+
+ if constexpr (chrono::__is_duration<_ChronoT>::value) {
+ // [time.format]/6
+ // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,
+ // etc.), then a specialization of duration is interpreted as the time of
+ // day elapsed since midnight.
+ uint64_t __sec = chrono::duration_cast<chrono::seconds>(__value).count();
+ __sec %= 24 * 3600;
+ __result.tm_hour = __sec / 3600;
+ __sec %= 3600;
+ __result.tm_min = __sec / 60;
+ __result.tm_sec = __sec % 60;
+ } else if constexpr (same_as<_ChronoT, chrono::day>)
+ __result.tm_mday = static_cast<unsigned>(__value);
+ else if constexpr (same_as<_ChronoT, chrono::month>)
+ __result.tm_mon = static_cast<unsigned>(__value) - 1;
+ else if constexpr (same_as<_ChronoT, chrono::year>)
+ __result.tm_year = static_cast<int>(__value) - 1900;
+ else if constexpr (same_as<_ChronoT, chrono::weekday>)
+ __result.tm_wday = __value.c_encoding();
+ else if constexpr (same_as<_ChronoT, chrono::weekday_indexed> || same_as<_ChronoT, chrono::weekday_last>)
+ __result.tm_wday = __value.weekday().c_encoding();
+ else if constexpr (same_as<_ChronoT, chrono::month_day>) {
+ __result.tm_mday = static_cast<unsigned>(__value.day());
+ __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
+ } else if constexpr (same_as<_ChronoT, chrono::month_day_last>) {
+ __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
+ } else if constexpr (same_as<_ChronoT, chrono::month_weekday> || same_as<_ChronoT, chrono::month_weekday_last>) {
+ __result.tm_wday = __value.weekday_indexed().weekday().c_encoding();
+ __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
+ } else if constexpr (same_as<_ChronoT, chrono::year_month>) {
+ __result.tm_year = static_cast<int>(__value.year()) - 1900;
+ __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
+ } else if constexpr (same_as<_ChronoT, chrono::year_month_day> || same_as<_ChronoT, chrono::year_month_day_last>) {
+ return std::__convert_to_tm<_Tm>(
+ chrono::year_month_day{__value}, chrono::weekday{static_cast<chrono::sys_days>(__value)});
+ } else if constexpr (same_as<_ChronoT, chrono::year_month_weekday> ||
+ same_as<_ChronoT, chrono::year_month_weekday_last>) {
+ return std::__convert_to_tm<_Tm>(chrono::year_month_day{static_cast<chrono::sys_days>(__value)}, __value.weekday());
+ } else
+ static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization");
+
+ return __result;
+}
+
+#endif //if _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_CONVERT_TO_TM_H
diff --git a/libcxx/include/__chrono/day.h b/libcxx/include/__chrono/day.h
index d9fa4ffbc45e..35ecfcf9e5bd 100644
--- a/libcxx/include/__chrono/day.h
+++ b/libcxx/include/__chrono/day.h
@@ -27,18 +27,18 @@ namespace chrono
class day {
private:
- unsigned char __d;
+ unsigned char __d_;
public:
_LIBCPP_HIDE_FROM_ABI day() = default;
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d; return *this; }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d_(static_cast<unsigned char>(__val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
_LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
};
diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h
index c502574fb267..afcc38b5cfc0 100644
--- a/libcxx/include/__chrono/duration.h
+++ b/libcxx/include/__chrono/duration.h
@@ -11,9 +11,12 @@
#define _LIBCPP___CHRONO_DURATION_H
#include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_floating_point.h>
#include <limits>
#include <ratio>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -151,7 +154,7 @@ typename enable_if
>::type
floor(const duration<_Rep, _Period>& __d)
{
- _ToDuration __t = duration_cast<_ToDuration>(__d);
+ _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
if (__t > __d)
__t = __t - _ToDuration{1};
return __t;
@@ -166,7 +169,7 @@ typename enable_if
>::type
ceil(const duration<_Rep, _Period>& __d)
{
- _ToDuration __t = duration_cast<_ToDuration>(__d);
+ _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
if (__t < __d)
__t = __t + _ToDuration{1};
return __t;
@@ -181,7 +184,7 @@ typename enable_if
>::type
round(const duration<_Rep, _Period>& __d)
{
- _ToDuration __lower = floor<_ToDuration>(__d);
+ _ToDuration __lower = chrono::floor<_ToDuration>(__d);
_ToDuration __upper = __lower + _ToDuration{1};
auto __lowerDiff = __d - __lower;
auto __upperDiff = __upper - __d;
@@ -278,18 +281,18 @@ public:
_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_SINCE_CXX17 duration& operator++() {++__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) {return duration(__rep_++);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {--__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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_SINCE_CXX17 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
// special values
@@ -534,67 +537,67 @@ inline namespace literals
inline namespace chrono_literals
{
- constexpr chrono::hours operator""h(unsigned long long __h)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
{
return chrono::duration<long double, nano> (__ns);
}
@@ -612,4 +615,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP___CHRONO_DURATION_H
diff --git a/libcxx/include/__chrono/file_clock.h b/libcxx/include/__chrono/file_clock.h
index b8e08e78ba72..ef62b8329599 100644
--- a/libcxx/include/__chrono/file_clock.h
+++ b/libcxx/include/__chrono/file_clock.h
@@ -61,7 +61,7 @@ struct _FilesystemClock {
typedef chrono::time_point<_FilesystemClock> time_point;
_LIBCPP_EXPORTED_FROM_ABI
- static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+ static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
new file mode 100644
index 000000000000..2015783acbbb
--- /dev/null
+++ b/libcxx/include/__chrono/formatter.h
@@ -0,0 +1,716 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_FORMATTER_H
+#define _LIBCPP___CHRONO_FORMATTER_H
+
+#include <__chrono/calendar.h>
+#include <__chrono/convert_to_tm.h>
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/hh_mm_ss.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
+#include <__chrono/ostream.h>
+#include <__chrono/parser_std_format_spec.h>
+#include <__chrono/statically_widen.h>
+#include <__chrono/time_point.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/format_functions.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__memory/addressof.h>
+#include <cmath>
+#include <ctime>
+#include <sstream>
+#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 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+namespace __formatter {
+
+/// Formats a time based on a tm struct.
+///
+/// This formatter passes the formatting to time_put which uses strftime. When
+/// the value is outside the valid range it's unspecified what strftime will
+/// output. For example weekday 8 can print 1 when the day is processed modulo
+/// 7 since that handles the Sunday for 0-based weekday. It can also print 8 if
+/// 7 is handled as a special case.
+///
+/// The Standard doesn't specify what to do in this case so the result depends
+/// on the result of the underlying code.
+///
+/// \pre When the (abbreviated) weekday or month name are used, the caller
+/// validates whether the value is valid. So the caller handles that
+/// requirement of Table 97: Meaning of conversion specifiers
+/// [tab:time.format.spec].
+///
+/// When no chrono-specs are provided it uses the stream formatter.
+
+// For tiny ratios it's not possible to convert a duration to a hh_mm_ss. This
+// fails compile-time due to the limited precision of the ratio (64-bit is too
+// small). Therefore a duration uses its own conversion.
+template <class _CharT, class _Tp>
+ requires(chrono::__is_duration<_Tp>::value)
+_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, basic_stringstream<_CharT>& __sstr) {
+ __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
+
+ auto __fraction = __value - chrono::duration_cast<chrono::seconds>(__value);
+ if constexpr (chrono::treat_as_floating_point_v<typename _Tp::rep>)
+ // When the floating-point value has digits itself they are ignored based
+ // on the wording in [tab:time.format.spec]
+ // If the precision of the input cannot be exactly represented with
+ // seconds, then the format is a decimal floating-point number with a
+ // fixed format and a precision matching that of the precision of the
+ // input (or to a microseconds precision if the conversion to
+ // floating-point decimal seconds cannot be made within 18 fractional
+ // digits).
+ //
+ // This matches the behaviour of MSVC STL, fmtlib interprets this
+ // differently and uses 3 decimals.
+ // https://godbolt.org/z/6dsbnW8ba
+ std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{:0{}.0f}"),
+ __fraction.count(),
+ chrono::hh_mm_ss<_Tp>::fractional_width);
+ else
+ std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{:0{}}"),
+ __fraction.count(),
+ chrono::hh_mm_ss<_Tp>::fractional_width);
+}
+
+template <class _Tp>
+consteval bool __use_fraction() {
+ if constexpr (chrono::__is_duration<_Tp>::value)
+ return chrono::hh_mm_ss<_Tp>::fractional_width;
+ else
+ return false;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& __sstr) {
+ if (__year < 0) {
+ __sstr << _CharT('-');
+ __year = -__year;
+ }
+
+ // TODO FMT Write an issue
+ // If the result has less than four digits it is zero-padded with 0 to two digits.
+ // is less -> has less
+ // left-padded -> zero-padded, otherwise the proper value would be 000-0.
+
+ // Note according to the wording it should be left padded, which is odd.
+ __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:04}"), __year);
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_CharT>& __sstr) {
+ // TODO FMT Write an issue
+ // [tab:time.format.spec]
+ // %C The year divided by 100 using floored division. If the result is a
+ // single decimal digit, it is prefixed with 0.
+
+ bool __negative = __year < 0;
+ int __century = (__year - (99 * __negative)) / 100; // floored division
+ __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
+}
+
+template <class _CharT, class _Tp>
+_LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
+ const _Tp& __value, basic_stringstream<_CharT>& __sstr, basic_string_view<_CharT> __chrono_specs) {
+ tm __t = std::__convert_to_tm<tm>(__value);
+ const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc());
+ for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) {
+ if (*__it == _CharT('%')) {
+ auto __s = __it;
+ ++__it;
+ // We only handle the types that can't be directly handled by time_put.
+ // (as an optimization n, t, and % are also handled directly.)
+ switch (*__it) {
+ case _CharT('n'):
+ __sstr << _CharT('\n');
+ break;
+ case _CharT('t'):
+ __sstr << _CharT('\t');
+ break;
+ case _CharT('%'):
+ __sstr << *__it;
+ break;
+
+ case _CharT('C'): {
+ // strftime's output is only defined in the range [00, 99].
+ int __year = __t.tm_year + 1900;
+ if (__year < 1000 || __year > 9999)
+ __formatter::__format_century(__year, __sstr);
+ else
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ } break;
+
+ case _CharT('j'):
+ if constexpr (chrono::__is_duration<_Tp>::value)
+ // Converting a duration where the period has a small ratio to days
+ // may fail to compile. This due to loss of precision in the
+ // conversion. In order to avoid that issue convert to seconds as
+ // an intemediate step.
+ __sstr << chrono::duration_cast<chrono::days>(chrono::duration_cast<chrono::seconds>(__value)).count();
+ else
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ break;
+
+ case _CharT('q'):
+ if constexpr (chrono::__is_duration<_Tp>::value) {
+ __sstr << chrono::__units_suffix<_CharT, typename _Tp::period>();
+ break;
+ }
+ __builtin_unreachable();
+
+ case _CharT('Q'):
+ // TODO FMT Determine the proper ideas
+ // - Should it honour the precision?
+ // - Shoult it honour the locale setting for the separators?
+ // The wording for Q doesn't use the word locale and the effect of
+ // precision is unspecified.
+ //
+ // MSVC STL ignores precision but uses separator
+ // FMT honours precision and has a bug for separator
+ // https://godbolt.org/z/78b7sMxns
+ if constexpr (chrono::__is_duration<_Tp>::value) {
+ __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{}"), __value.count());
+ break;
+ }
+ __builtin_unreachable();
+
+ case _CharT('S'):
+ case _CharT('T'):
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ if constexpr (__use_fraction<_Tp>())
+ __formatter::__format_sub_seconds(__value, __sstr);
+ break;
+
+ // Unlike time_put and strftime the formatting library requires %Y
+ //
+ // [tab:time.format.spec]
+ // The year as a decimal number. If the result is less than four digits
+ // it is left-padded with 0 to four digits.
+ //
+ // This means years in the range (-1000, 1000) need manual formatting.
+ // It's unclear whether %EY needs the same treatment. For example the
+ // Japanese EY contains the era name and year. This is zero-padded to 2
+ // digits in time_put (note that older glibc versions didn't do
+ // padding.) However most eras won't reach 100 years, let alone 1000.
+ // So padding to 4 digits seems unwanted for Japanese.
+ //
+ // The same applies to %Ex since that too depends on the era.
+ //
+ // %x the locale's date representation is currently doesn't handle the
+ // zero-padding too.
+ //
+ // The 4 digits can be implemented better at a later time. On POSIX
+ // systems the required information can be extracted by nl_langinfo
+ // https://man7.org/linux/man-pages/man3/nl_langinfo.3.html
+ //
+ // Note since year < -1000 is expected to be rare it uses the more
+ // expensive year routine.
+ //
+ // TODO FMT evaluate the comment above.
+
+# if defined(__GLIBC__) || defined(_AIX)
+ case _CharT('y'):
+ // Glibc fails for negative values, AIX for positive values too.
+ __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);
+ break;
+# endif // defined(__GLIBC__) || defined(_AIX)
+
+ case _CharT('Y'): {
+ int __year = __t.tm_year + 1900;
+ if (__year < 1000)
+ __formatter::__format_year(__year, __sstr);
+ else
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ } break;
+
+ case _CharT('F'): {
+ int __year = __t.tm_year + 1900;
+ if (__year < 1000) {
+ __formatter::__format_year(__year, __sstr);
+ __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+ } else
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ } break;
+
+ case _CharT('O'):
+ if constexpr (__use_fraction<_Tp>()) {
+ // Handle OS using the normal representation for the non-fractional
+ // part. There seems to be no locale information regarding how the
+ // fractional part should be formatted.
+ if (*(__it + 1) == 'S') {
+ ++__it;
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ __formatter::__format_sub_seconds(__value, __sstr);
+ break;
+ }
+ }
+ [[fallthrough]];
+ case _CharT('E'):
+ ++__it;
+ [[fallthrough]];
+ default:
+ __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
+ break;
+ }
+ } else {
+ __sstr << *__it;
+ }
+ }
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
+ if constexpr (same_as<_Tp, chrono::day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_weekday>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::year_month>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::year_month_day>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
+ return __value.weekday().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
+ return __value.weekday().ok();
+ else
+ static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
+ if constexpr (same_as<_Tp, chrono::day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
+ return __value.weekday().ok();
+ else if constexpr (same_as<_Tp, chrono::weekday_last>)
+ return __value.weekday().ok();
+ else if constexpr (same_as<_Tp, chrono::month_day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_weekday>)
+ return __value.weekday_indexed().ok();
+ else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
+ return __value.weekday_indexed().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::year_month_day>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
+ return __value.weekday().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
+ return __value.weekday().ok();
+ else
+ static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
+ if constexpr (same_as<_Tp, chrono::day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_weekday>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::year_month>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::year_month_day>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
+ return __value.ok();
+ else
+ static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
+ if constexpr (same_as<_Tp, chrono::day>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month>)
+ return __value.ok();
+ else if constexpr (same_as<_Tp, chrono::year>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::weekday_last>)
+ return true;
+ else if constexpr (same_as<_Tp, chrono::month_day>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::month_day_last>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::month_weekday>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_day>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
+ return __value.month().ok();
+ else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
+ return __value.month().ok();
+ else
+ static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
+}
+
+template <class _CharT, class _Tp>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_chrono(const _Tp& __value,
+ auto& __ctx,
+ __format_spec::__parsed_specifications<_CharT> __specs,
+ basic_string_view<_CharT> __chrono_specs) -> decltype(__ctx.out()) {
+ basic_stringstream<_CharT> __sstr;
+ // [time.format]/2
+ // 2.1 - the "C" locale if the L option is not present in chrono-format-spec, otherwise
+ // 2.2 - the locale passed to the formatting function if any, otherwise
+ // 2.3 - the global locale.
+ // Note that the __ctx's locale() call does 2.2 and 2.3.
+ if (__specs.__chrono_.__locale_specific_form_)
+ __sstr.imbue(__ctx.locale());
+ else
+ __sstr.imbue(locale::classic());
+
+ if (__chrono_specs.empty())
+ __sstr << __value;
+ else {
+ if constexpr (chrono::__is_duration<_Tp>::value) {
+ if (__value < __value.zero())
+ __sstr << _CharT('-');
+ __formatter::__format_chrono_using_chrono_specs(chrono::abs(__value), __sstr, __chrono_specs);
+ // TODO FMT When keeping the precision it will truncate the string.
+ // Note that the behaviour what the precision does isn't specified.
+ __specs.__precision_ = -1;
+ } else {
+ // Test __weekday_name_ before __weekday_ to give a better error.
+ if (__specs.__chrono_.__weekday_name_ && !__formatter::__weekday_name_ok(__value))
+ std::__throw_format_error("formatting a weekday name needs a valid weekday");
+
+ if (__specs.__chrono_.__weekday_ && !__formatter::__weekday_ok(__value))
+ std::__throw_format_error("formatting a weekday needs a valid weekday");
+
+ if (__specs.__chrono_.__day_of_year_ && !__formatter::__date_ok(__value))
+ std::__throw_format_error("formatting a day of year needs a valid date");
+
+ if (__specs.__chrono_.__week_of_year_ && !__formatter::__date_ok(__value))
+ std::__throw_format_error("formatting a week of year needs a valid date");
+
+ if (__specs.__chrono_.__month_name_ && !__formatter::__month_name_ok(__value))
+ std::__throw_format_error("formatting a month name from an invalid month number");
+
+ __formatter::__format_chrono_using_chrono_specs(__value, __sstr, __chrono_specs);
+ }
+ }
+
+ // TODO FMT Use the stringstream's view after P0408R7 has been implemented.
+ basic_string<_CharT> __str = __sstr.str();
+ return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+}
+
+} // namespace __formatter
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_chrono {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(
+ basic_format_parse_context<_CharT>& __parse_ctx, __format_spec::__fields __fields, __format_spec::__flags __flags)
+ -> decltype(__parse_ctx.begin()) {
+ return __parser_.__parse(__parse_ctx, __fields, __flags);
+ }
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(const _Tp& __value, auto& __ctx) const -> decltype(__ctx.out()) const {
+ return __formatter::__format_chrono(
+ __value, __ctx, __parser_.__parser_.__get_parsed_chrono_specifications(__ctx), __parser_.__chrono_specs_);
+ }
+
+ __format_spec::__parser_chrono<_CharT> __parser_;
+};
+
+template <class _Rep, class _Period, __fmt_char_type _CharT>
+struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ // [time.format]/1
+ // Giving a precision specification in the chrono-format-spec is valid only
+ // for std::chrono::duration types where the representation type Rep is a
+ // floating-point type. For all other Rep types, an exception of type
+ // format_error is thrown if the chrono-format-spec contains a precision
+ // specification.
+ //
+ // Note this doesn't refer to chrono::treat_as_floating_point_v<_Rep>.
+ if constexpr (std::floating_point<_Rep>)
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono_fractional, __format_spec::__flags::__duration);
+ else
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__duration);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::day, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__day);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday_indexed, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday_last, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_day, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_day);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_day_last, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_weekday, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_weekday_last, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year_month);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_day, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_day_last, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_weekday, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
+ }
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_weekday_last, _CharT>
+ : public __formatter_chrono<_CharT> {
+public:
+ using _Base = __formatter_chrono<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
+ }
+};
+
+#endif // if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_FORMATTER_H
diff --git a/libcxx/include/__chrono/hh_mm_ss.h b/libcxx/include/__chrono/hh_mm_ss.h
index 6b3c5c09e68e..fd61cbe8f845 100644
--- a/libcxx/include/__chrono/hh_mm_ss.h
+++ b/libcxx/include/__chrono/hh_mm_ss.h
@@ -57,33 +57,33 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
_LIBCPP_HIDE_FROM_ABI 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()))
+ __is_neg_(__d < _Duration(0)),
+ __h_(chrono::duration_cast<chrono::hours> (chrono::abs(__d))),
+ __m_(chrono::duration_cast<chrono::minutes>(chrono::abs(__d) - hours())),
+ __s_(chrono::duration_cast<chrono::seconds>(chrono::abs(__d) - hours() - minutes())),
+ __f_(chrono::duration_cast<precision> (chrono::abs(__d) - hours() - minutes() - seconds()))
{}
- _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; }
- _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h; }
- _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s; }
- _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f_; }
_LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept
{
- auto __dur = __h + __m + __s + __f;
- return __is_neg ? -__dur : __dur;
+ auto __dur = __h_ + __m_ + __s_ + __f_;
+ return __is_neg_ ? -__dur : __dur;
}
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }
private:
- bool __is_neg;
- chrono::hours __h;
- chrono::minutes __m;
- chrono::seconds __s;
- precision __f;
+ bool __is_neg_;
+ chrono::hours __h_;
+ chrono::minutes __m_;
+ chrono::seconds __s_;
+ precision __f_;
};
_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
diff --git a/libcxx/include/__chrono/month.h b/libcxx/include/__chrono/month.h
index 5aeb5b397182..e929f248842e 100644
--- a/libcxx/include/__chrono/month.h
+++ b/libcxx/include/__chrono/month.h
@@ -12,6 +12,7 @@
#include <__chrono/duration.h>
#include <__config>
+#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -26,18 +27,18 @@ namespace chrono
class month {
private:
- unsigned char __m;
+ unsigned char __m_;
public:
_LIBCPP_HIDE_FROM_ABI month() = default;
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m; return *this; }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m_(static_cast<unsigned char>(__val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
_LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
};
@@ -45,25 +46,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month& __lhs, const month& __rhs) noexcept
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator< (const month& __lhs, const month& __rhs) noexcept
-{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const month& __lhs, const month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const month& __lhs, const month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
+ return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
+}
_LIBCPP_HIDE_FROM_ABI inline constexpr
month operator+ (const month& __lhs, const months& __rhs) noexcept
diff --git a/libcxx/include/__chrono/month_weekday.h b/libcxx/include/__chrono/month_weekday.h
index 270051397017..01cdf76d84bb 100644
--- a/libcxx/include/__chrono/month_weekday.h
+++ b/libcxx/include/__chrono/month_weekday.h
@@ -27,14 +27,14 @@ namespace chrono
class month_weekday {
private:
- chrono::month __m;
- chrono::weekday_indexed __wdi;
+ chrono::month __m_;
+ chrono::weekday_indexed __wdi_;
public:
_LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
- : __m{__mval}, __wdi{__wdival} {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
+ : __m_{__mval}, __wdi_{__wdival} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
@@ -63,14 +63,14 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
class month_weekday_last {
- chrono::month __m;
- chrono::weekday_last __wdl;
+ chrono::month __m_;
+ chrono::weekday_last __wdl_;
public:
_LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
- : __m{__mval}, __wdl{__wdlval} {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
+ : __m_{__mval}, __wdl_{__wdlval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
diff --git a/libcxx/include/__chrono/monthday.h b/libcxx/include/__chrono/monthday.h
index 485f0d4299b5..c0ee3e4a94fd 100644
--- a/libcxx/include/__chrono/monthday.h
+++ b/libcxx/include/__chrono/monthday.h
@@ -14,6 +14,7 @@
#include <__chrono/day.h>
#include <__chrono/month.h>
#include <__config>
+#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,26 +29,26 @@ namespace chrono
class month_day {
private:
- chrono::month __m;
- chrono::day __d;
+ chrono::month __m_;
+ chrono::day __d_;
public:
_LIBCPP_HIDE_FROM_ABI month_day() = default;
_LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __m{__mval}, __d{__dval} {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
+ : __m_{__mval}, __d_{__dval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
_LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
bool month_day::ok() const noexcept
{
- if (!__m.ok()) return false;
- const unsigned __dval = static_cast<unsigned>(__d);
+ 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);
+ const unsigned __mval = static_cast<unsigned>(__m_);
if (__mval == 2) return false;
if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
return __dval == 30;
@@ -58,9 +59,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
+ if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
+ return __c;
+ return __lhs.day() <=> __rhs.day();
+}
_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(const month& __lhs, const day& __rhs) noexcept
@@ -82,58 +85,24 @@ _LIBCPP_HIDE_FROM_ABI constexpr
month_day operator/(const day& __lhs, int __rhs) noexcept
{ return month(__rhs) / __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI 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(); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-
-
class month_day_last {
private:
- chrono::month __m;
+ chrono::month __m_;
public:
_LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept
- : __m{__val} {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok(); }
+ : __m_{__val} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
{ return __lhs.month() == __rhs.month(); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __lhs.month() < __rhs.month(); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
-{ return !(__lhs < __rhs); }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
+operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
+ return __lhs.month() <=> __rhs.month();
+}
_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day_last operator/(const month& __lhs, last_spec) noexcept
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
new file mode 100644
index 000000000000..30a04bd2658b
--- /dev/null
+++ b/libcxx/include/__chrono/ostream.h
@@ -0,0 +1,238 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_OSTREAM_H
+#define _LIBCPP___CHRONO_OSTREAM_H
+
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
+#include <__chrono/statically_widen.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/format_functions.h>
+#include <ostream>
+#include <ratio>
+
+#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_FORMAT)
+
+namespace chrono {
+
+// Depending on the type the return is a const _CharT* or a basic_string<_CharT>
+template <class _CharT, class _Period>
+_LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
+ // TODO FMT LWG issue the suffixes are always char and not STATICALLY-WIDEN'ed.
+ if constexpr (same_as<typename _Period::type, atto>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "as");
+ else if constexpr (same_as<typename _Period::type, femto>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "fs");
+ else if constexpr (same_as<typename _Period::type, pico>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "ps");
+ else if constexpr (same_as<typename _Period::type, nano>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
+ else if constexpr (same_as<typename _Period::type, micro>)
+# ifndef _LIBCPP_HAS_NO_UNICODE
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
+# else
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
+# endif
+ else if constexpr (same_as<typename _Period::type, milli>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");
+ else if constexpr (same_as<typename _Period::type, centi>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "cs");
+ else if constexpr (same_as<typename _Period::type, deci>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "ds");
+ else if constexpr (same_as<typename _Period::type, ratio<1>>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "s");
+ else if constexpr (same_as<typename _Period::type, deca>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "das");
+ else if constexpr (same_as<typename _Period::type, hecto>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "hs");
+ else if constexpr (same_as<typename _Period::type, kilo>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "ks");
+ else if constexpr (same_as<typename _Period::type, mega>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ms");
+ else if constexpr (same_as<typename _Period::type, giga>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "Gs");
+ else if constexpr (same_as<typename _Period::type, tera>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ts");
+ else if constexpr (same_as<typename _Period::type, peta>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ps");
+ else if constexpr (same_as<typename _Period::type, exa>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "Es");
+ else if constexpr (same_as<typename _Period::type, ratio<60>>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "min");
+ else if constexpr (same_as<typename _Period::type, ratio<3600>>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "h");
+ else if constexpr (same_as<typename _Period::type, ratio<86400>>)
+ return _LIBCPP_STATICALLY_WIDEN(_CharT, "d");
+ else if constexpr (_Period::den == 1)
+ return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "[{}]s"), _Period::num);
+ else
+ return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "[{}/{}]s"), _Period::num, _Period::den);
+}
+
+template <class _CharT, class _Traits, class _Rep, class _Period>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const duration<_Rep, _Period>& __d) {
+ basic_ostringstream<_CharT, _Traits> __s;
+ __s.flags(__os.flags());
+ __s.imbue(__os.getloc());
+ __s.precision(__os.precision());
+ __s << __d.count() << chrono::__units_suffix<_CharT, _Period>();
+ return __os << __s.str();
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const day& __d) {
+ return __os
+ << (__d.ok()
+ ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%d}"), __d)
+ // Note this error differs from the wording of the Standard. The
+ // Standard wording doesn't work well on AIX or Windows. There
+ // the formatted day seems to be either modulo 100 or completely
+ // omitted. Judging by the wording this is valid.
+ // TODO FMT Write a paper of file an LWG issue.
+ : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02} is not a valid day"), static_cast<unsigned>(__d)));
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const month& __m) {
+ return __os << (__m.ok() ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%b}"), __m)
+ : std::format(__os.getloc(),
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{} is not a valid month"),
+ static_cast<unsigned>(__m))); // TODO FMT Standard mandated locale isn't used.
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year& __y) {
+ return __os << (__y.ok() ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%Y}"), __y)
+ : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%Y} is not a valid year"), __y));
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday& __wd) {
+ return __os << (__wd.ok() ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%a}"), __wd)
+ : std::format(__os.getloc(), // TODO FMT Standard mandated locale isn't used.
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{} is not a valid weekday"),
+ static_cast<unsigned>(__wd.c_encoding())));
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday_indexed& __wdi) {
+ auto __i = __wdi.index();
+ return __os << (__i >= 1 && __i <= 5
+ ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[{}]"), __wdi.weekday(), __i)
+ : std::format(__os.getloc(),
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[{} is not a valid index]"),
+ __wdi.weekday(),
+ __i));
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday_last& __wdl) {
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[last]"), __wdl.weekday());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const month_day& __md) {
+ // TODO FMT The Standard allows 30th of February to be printed.
+ // It would be nice to show an error message instead.
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{}"), __md.month(), __md.day());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const month_day_last& __mdl) {
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/last"), __mdl.month());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const month_weekday& __mwd) {
+ return __os << std::format(
+ __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{:L}"), __mwd.month(), __mwd.weekday_indexed());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const month_weekday_last& __mwdl) {
+ return __os << std::format(
+ __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{:L}"), __mwdl.month(), __mwdl.weekday_last());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month& __ym) {
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}"), __ym.year(), __ym.month());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_day& __ymd) {
+ return __os << (__ymd.ok() ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%F}"), __ymd)
+ : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%F} is not a valid date"), __ymd));
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_day_last& __ymdl) {
+ return __os << std::format(
+ __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}"), __ymdl.year(), __ymdl.month_day_last());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_weekday& __ymwd) {
+ return __os << std::format(
+ __os.getloc(),
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}/{:L}"),
+ __ymwd.year(),
+ __ymwd.month(),
+ __ymwd.weekday_indexed());
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_weekday_last& __ymwdl) {
+ return __os << std::format(
+ __os.getloc(),
+ _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}/{:L}"),
+ __ymwdl.year(),
+ __ymwdl.month(),
+ __ymwdl.weekday_last());
+}
+
+} // namespace chrono
+
+#endif //if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_OSTREAM_H
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
new file mode 100644
index 000000000000..dbcfe6da608a
--- /dev/null
+++ b/libcxx/include/__chrono/parser_std_format_spec.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___CHRONO_PARSER_STD_FORMAT_SPEC_H
+#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
+
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter_string.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 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+namespace __format_spec {
+
+// By not placing this constant in the formatter class it's not duplicated for char and wchar_t
+inline constexpr __fields __fields_chrono_fractional{
+ .__precision_ = true, .__locale_specific_form_ = true, .__type_ = false};
+inline constexpr __fields __fields_chrono{.__locale_specific_form_ = true, .__type_ = false};
+
+/// Flags available or required in a chrono type.
+///
+/// The caller of the chrono formatter lists the types it has available and the
+/// validation tests whether the requested type spec (e.g. %M) is available in
+/// the formatter.
+/// When the type in the chrono-format-spec isn't present in the data a
+/// \ref format_error is thrown.
+enum class __flags {
+ __second = 0x1,
+ __minute = 0x2,
+ __hour = 0x4,
+ __time = __hour | __minute | __second,
+
+ __day = 0x8,
+ __month = 0x10,
+ __year = 0x20,
+
+ __weekday = 0x40,
+
+ __month_day = __day | __month,
+ __month_weekday = __weekday | __month,
+ __year_month = __month | __year,
+ __date = __day | __month | __year | __weekday,
+
+ __date_time = __date | __time,
+
+ __duration = 0x80 | __time,
+
+ __time_zone = 0x100,
+
+ __clock = __date_time | __time_zone
+};
+
+_LIBCPP_HIDE_FROM_ABI constexpr __flags operator&(__flags __lhs, __flags __rhs) {
+ return static_cast<__flags>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs));
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_second(__flags __flags) {
+ if ((__flags & __flags::__second) != __flags::__second)
+ std::__throw_format_error("The supplied date time doesn't contain a second");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_minute(__flags __flags) {
+ if ((__flags & __flags::__minute) != __flags::__minute)
+ std::__throw_format_error("The supplied date time doesn't contain a minute");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_hour(__flags __flags) {
+ if ((__flags & __flags::__hour) != __flags::__hour)
+ std::__throw_format_error("The supplied date time doesn't contain an hour");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_time(__flags __flags) {
+ if ((__flags & __flags::__time) != __flags::__time)
+ std::__throw_format_error("The supplied date time doesn't contain a time");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_day(__flags __flags) {
+ if ((__flags & __flags::__day) != __flags::__day)
+ std::__throw_format_error("The supplied date time doesn't contain a day");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_month(__flags __flags) {
+ if ((__flags & __flags::__month) != __flags::__month)
+ std::__throw_format_error("The supplied date time doesn't contain a month");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_year(__flags __flags) {
+ if ((__flags & __flags::__year) != __flags::__year)
+ std::__throw_format_error("The supplied date time doesn't contain a year");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date(__flags __flags) {
+ if ((__flags & __flags::__date) != __flags::__date)
+ std::__throw_format_error("The supplied date time doesn't contain a date");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date_or_duration(__flags __flags) {
+ if (((__flags & __flags::__date) != __flags::__date) && ((__flags & __flags::__duration) != __flags::__duration))
+ std::__throw_format_error("The supplied date time doesn't contain a date or duration");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date_time(__flags __flags) {
+ if ((__flags & __flags::__date_time) != __flags::__date_time)
+ std::__throw_format_error("The supplied date time doesn't contain a date and time");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_weekday(__flags __flags) {
+ if ((__flags & __flags::__weekday) != __flags::__weekday)
+ std::__throw_format_error("The supplied date time doesn't contain a weekday");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_duration(__flags __flags) {
+ if ((__flags & __flags::__duration) != __flags::__duration)
+ std::__throw_format_error("The supplied date time doesn't contain a duration");
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {
+ if ((__flags & __flags::__time_zone) != __flags::__time_zone)
+ std::__throw_format_error("The supplied date time doesn't contain a time zone");
+}
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser_chrono {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields, __flags __flags)
+ -> decltype(__parse_ctx.begin()) {
+ const _CharT* __begin = __parser_.__parse(__parse_ctx, __fields);
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ const _CharT* __last = __parse_chrono_specs(__begin, __end, __flags);
+ __chrono_specs_ = basic_string_view<_CharT>{__begin, __last};
+
+ return __last;
+ }
+
+ __parser<_CharT> __parser_;
+ basic_string_view<_CharT> __chrono_specs_;
+
+private:
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+ __parse_chrono_specs(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 != _CharT('%') && *__begin != _CharT('}'))
+ std::__throw_format_error("Expected '%' or '}' in the chrono format-string");
+
+ do {
+ switch (*__begin) {
+ case _CharT('{'):
+ std::__throw_format_error("The chrono-specs contains a '{'");
+
+ case _CharT('}'):
+ return __begin;
+
+ case _CharT('%'):
+ __parse_conversion_spec(__begin, __end, __flags);
+ [[fallthrough]];
+
+ default:
+ // All other literals
+ ++__begin;
+ }
+
+ } while (__begin != __end && *__begin != _CharT('}'));
+
+ return __begin;
+ }
+
+ /// \pre *__begin == '%'
+ /// \post __begin points at the end parsed conversion-spec
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ __parse_conversion_spec(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
+ ++__begin;
+ if (__begin == __end)
+ std::__throw_format_error("End of input while parsing the modifier chrono conversion-spec");
+
+ switch (*__begin) {
+ case _CharT('n'):
+ case _CharT('t'):
+ case _CharT('%'):
+ break;
+
+ case _CharT('S'):
+ __format_spec::__validate_second(__flags);
+ break;
+
+ case _CharT('M'):
+ __format_spec::__validate_minute(__flags);
+ break;
+
+ case _CharT('p'): // TODO FMT does the formater require an hour or a time?
+ case _CharT('H'):
+ case _CharT('I'):
+ __validate_hour(__flags);
+ break;
+
+ case _CharT('r'):
+ case _CharT('R'):
+ case _CharT('T'):
+ case _CharT('X'):
+ __format_spec::__validate_time(__flags);
+ break;
+
+ case _CharT('d'):
+ case _CharT('e'):
+ __format_spec::__validate_day(__flags);
+ break;
+
+ case _CharT('b'):
+ case _CharT('h'):
+ case _CharT('B'):
+ __parser_.__month_name_ = true;
+ [[fallthrough]];
+ case _CharT('m'):
+ __format_spec::__validate_month(__flags);
+ break;
+
+ case _CharT('y'):
+ case _CharT('C'):
+ case _CharT('Y'):
+ __format_spec::__validate_year(__flags);
+ break;
+
+ case _CharT('j'):
+ __parser_.__day_of_year_ = true;
+ __format_spec::__validate_date_or_duration(__flags);
+ break;
+
+ case _CharT('g'):
+ case _CharT('G'):
+ case _CharT('U'):
+ case _CharT('V'):
+ case _CharT('W'):
+ __parser_.__week_of_year_ = true;
+ [[fallthrough]];
+ case _CharT('x'):
+ case _CharT('D'):
+ case _CharT('F'):
+ __format_spec::__validate_date(__flags);
+ break;
+
+ case _CharT('c'):
+ __format_spec::__validate_date_time(__flags);
+ break;
+
+ case _CharT('a'):
+ case _CharT('A'):
+ __parser_.__weekday_name_ = true;
+ [[fallthrough]];
+ case _CharT('u'):
+ case _CharT('w'):
+ __parser_.__weekday_ = true;
+ __validate_weekday(__flags);
+ __format_spec::__validate_weekday(__flags);
+ break;
+
+ case _CharT('q'):
+ case _CharT('Q'):
+ __format_spec::__validate_duration(__flags);
+ break;
+
+ case _CharT('E'):
+ __parse_modifier_E(__begin, __end, __flags);
+ break;
+
+ case _CharT('O'):
+ __parse_modifier_O(__begin, __end, __flags);
+ break;
+
+ case _CharT('z'):
+ case _CharT('Z'):
+ // Currently there's no time zone information. However some clocks have a
+ // hard-coded "time zone", for these clocks the information can be used.
+ // TODO FMT implement time zones.
+ __format_spec::__validate_time_zone(__flags);
+ break;
+
+ default: // unknown type;
+ std::__throw_format_error("The date time type specifier is invalid");
+ }
+ }
+
+ /// \pre *__begin == 'E'
+ /// \post __begin is incremented by one.
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ __parse_modifier_E(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
+ ++__begin;
+ if (__begin == __end)
+ std::__throw_format_error("End of input while parsing the modifier E");
+
+ switch (*__begin) {
+ case _CharT('X'):
+ __format_spec::__validate_time(__flags);
+ break;
+
+ case _CharT('y'):
+ case _CharT('C'):
+ case _CharT('Y'):
+ __format_spec::__validate_year(__flags);
+ break;
+
+ case _CharT('x'):
+ __format_spec::__validate_date(__flags);
+ break;
+
+ case _CharT('c'):
+ __format_spec::__validate_date_time(__flags);
+ break;
+
+ case _CharT('z'):
+ // Currently there's no time zone information. However some clocks have a
+ // hard-coded "time zone", for these clocks the information can be used.
+ // TODO FMT implement time zones.
+ __format_spec::__validate_time_zone(__flags);
+ break;
+
+ default:
+ std::__throw_format_error("The date time type specifier for modifier E is invalid");
+ }
+ }
+
+ /// \pre *__begin == 'O'
+ /// \post __begin is incremented by one.
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ __parse_modifier_O(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
+ ++__begin;
+ if (__begin == __end)
+ std::__throw_format_error("End of input while parsing the modifier O");
+
+ switch (*__begin) {
+ case _CharT('S'):
+ __format_spec::__validate_second(__flags);
+ break;
+
+ case _CharT('M'):
+ __format_spec::__validate_minute(__flags);
+ break;
+
+ case _CharT('I'):
+ case _CharT('H'):
+ __format_spec::__validate_hour(__flags);
+ break;
+
+ case _CharT('d'):
+ case _CharT('e'):
+ __format_spec::__validate_day(__flags);
+ break;
+
+ case _CharT('m'):
+ __format_spec::__validate_month(__flags);
+ break;
+
+ case _CharT('y'):
+ __format_spec::__validate_year(__flags);
+ break;
+
+ case _CharT('U'):
+ case _CharT('V'):
+ case _CharT('W'):
+ __parser_.__week_of_year_ = true;
+ __format_spec::__validate_date(__flags);
+ break;
+
+ case _CharT('u'):
+ case _CharT('w'):
+ __parser_.__weekday_ = true;
+ __format_spec::__validate_weekday(__flags);
+ break;
+
+ case _CharT('z'):
+ // Currently there's no time zone information. However some clocks have a
+ // hard-coded "time zone", for these clocks the information can be used.
+ // TODO FMT implement time zones.
+ __format_spec::__validate_time_zone(__flags);
+ break;
+
+ default:
+ std::__throw_format_error("The date time type specifier for modifier O is invalid");
+ }
+ }
+};
+
+} // namespace __format_spec
+
+#endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
diff --git a/libcxx/include/__chrono/statically_widen.h b/libcxx/include/__chrono/statically_widen.h
new file mode 100644
index 000000000000..360b6c2c7d57
--- /dev/null
+++ b/libcxx/include/__chrono/statically_widen.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___CHRONO_STATICALLY_WIDEN_H
+#define _LIBCPP___CHRONO_STATICALLY_WIDEN_H
+
+// Implements the STATICALLY-WIDEN exposition-only function. ([time.general]/2)
+
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <__fmt_char_type _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {
+ if constexpr (same_as<_CharT, char>)
+ return __str;
+ else
+ return __wstr;
+}
+# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
+# else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+// Without this indirection the unit test test/libcxx/modules_include.sh.cpp
+// fails for the CI build "No wide characters". This seems like a bug.
+// TODO FMT investigate why this is needed.
+template <__fmt_char_type _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str) {
+ return __str;
+}
+# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CHRONO_STATICALLY_WIDEN_H
diff --git a/libcxx/include/__chrono/steady_clock.h b/libcxx/include/__chrono/steady_clock.h
index 657e5eef6c37..ba83351738dd 100644
--- a/libcxx/include/__chrono/steady_clock.h
+++ b/libcxx/include/__chrono/steady_clock.h
@@ -31,7 +31,7 @@ public:
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 _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = true;
static time_point now() _NOEXCEPT;
};
diff --git a/libcxx/include/__chrono/system_clock.h b/libcxx/include/__chrono/system_clock.h
index 2922b78a74cb..331db468013c 100644
--- a/libcxx/include/__chrono/system_clock.h
+++ b/libcxx/include/__chrono/system_clock.h
@@ -31,7 +31,7 @@ public:
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 _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
static time_point now() _NOEXCEPT;
static time_t to_time_t (const time_point& __t) _NOEXCEPT;
diff --git a/libcxx/include/__chrono/time_point.h b/libcxx/include/__chrono/time_point.h
index 63d67d77dd05..8a8fa2176d6c 100644
--- a/libcxx/include/__chrono/time_point.h
+++ b/libcxx/include/__chrono/time_point.h
@@ -12,8 +12,10 @@
#include <__chrono/duration.h>
#include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_convertible.h>
#include <limits>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -41,12 +43,12 @@ 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) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point() : __d_(duration::zero()) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
// conversions
template <class _Duration2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
time_point(const time_point<clock, _Duration2>& __t,
typename enable_if
<
@@ -56,12 +58,12 @@ public:
// observer
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
// special values
@@ -81,7 +83,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
namespace chrono {
template <class _ToDuration, class _Clock, class _Duration>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
time_point<_Clock, _ToDuration>
time_point_cast(const time_point<_Clock, _Duration>& __t)
{
@@ -98,7 +100,7 @@ typename enable_if
>::type
floor(const time_point<_Clock, _Duration>& __t)
{
- return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
+ return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
}
template <class _ToDuration, class _Clock, class _Duration>
@@ -110,7 +112,7 @@ typename enable_if
>::type
ceil(const time_point<_Clock, _Duration>& __t)
{
- return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
+ return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
}
template <class _ToDuration, class _Clock, class _Duration>
@@ -122,7 +124,7 @@ typename enable_if
>::type
round(const time_point<_Clock, _Duration>& __t)
{
- return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
+ return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
}
template <class _Rep, class _Period>
@@ -141,7 +143,7 @@ abs(duration<_Rep, _Period> __d)
// time_point ==
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -151,7 +153,7 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// time_point !=
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -161,7 +163,7 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// time_point <
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -171,7 +173,7 @@ operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// time_point >
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -181,7 +183,7 @@ operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// time_point <=
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -191,7 +193,7 @@ operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// time_point >=
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -201,7 +203,7 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
// 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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -212,7 +214,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
// 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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
@@ -222,7 +224,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura
// 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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -233,7 +235,7 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
// duration operator-(time_point x, time_point y);
template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename common_type<_Duration1, _Duration2>::type
operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
diff --git a/libcxx/include/__chrono/weekday.h b/libcxx/include/__chrono/weekday.h
index bad6781110f1..e0bc8a4cae2b 100644
--- a/libcxx/include/__chrono/weekday.h
+++ b/libcxx/include/__chrono/weekday.h
@@ -32,25 +32,25 @@ class weekday_last;
class weekday {
private:
- unsigned char __wd;
+ unsigned char __wd_;
_LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
public:
_LIBCPP_HIDE_FROM_ABI weekday() = default;
- _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
+ _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd_(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept
- : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
+ : __wd_(__weekday_from_days(__sysd.time_since_epoch().count())) {}
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept
- : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
+ : __wd_(__weekday_from_days(__locd.time_since_epoch().count())) {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd_ = (__wd_ == 6 ? 0 : __wd_ + 1); return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd_ = (__wd_ == 0 ? 6 : __wd_ - 1); return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
_LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;
- _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd <= 6; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd_ == 0u ? 7 : __wd_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_ <= 6; }
_LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
};
@@ -123,15 +123,15 @@ weekday& weekday::operator-=(const days& __dd) noexcept
class weekday_indexed {
private:
- chrono::weekday __wd;
- unsigned char __idx;
+ chrono::weekday __wd_;
+ unsigned char __idx_;
public:
_LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
- : __wd{__wdval}, __idx(__idxval) {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
+ : __wd_{__wdval}, __idx_(__idxval) {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_.ok() && __idx_ >= 1 && __idx_ <= 5; }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
@@ -145,12 +145,12 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex
class weekday_last {
private:
- chrono::weekday __wd;
+ chrono::weekday __wd_;
public:
_LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
- : __wd{__val} {}
- _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; }
- _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd.ok(); }
+ : __wd_{__val} {}
+ _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
diff --git a/libcxx/include/__chrono/year.h b/libcxx/include/__chrono/year.h
index c7f0027eba7b..79ee8a02b8fb 100644
--- a/libcxx/include/__chrono/year.h
+++ b/libcxx/include/__chrono/year.h
@@ -12,6 +12,7 @@
#include <__chrono/duration.h>
#include <__config>
+#include <compare>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -30,22 +31,22 @@ namespace chrono
class year {
private:
- short __y;
+ short __y_;
public:
_LIBCPP_HIDE_FROM_ABI year() = default;
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y_(static_cast<short>(__val)) {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y_; return *this; }
_LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
_LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
_LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y}; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y_}; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
- _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y_ % 4 == 0 && (__y_ % 100 != 0 || __y_ % 400 == 0); }
+ _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y_; }
_LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
_LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
_LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }
@@ -56,25 +57,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const year& __lhs, const year& __rhs) noexcept
{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator< (const year& __lhs, const year& __rhs) noexcept
-{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const year& __lhs, const year& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__rhs < __lhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const year& __lhs, const year& __rhs) noexcept
-{ return !(__lhs < __rhs); }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, const year& __rhs) noexcept {
+ return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
+}
_LIBCPP_HIDE_FROM_ABI inline constexpr
year operator+ (const year& __lhs, const years& __rhs) noexcept
@@ -102,8 +87,8 @@ year& year::operator-=(const years& __dy) noexcept
{ *this = *this - __dy; return *this; }
_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
- static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max()));
- return static_cast<int>(min()) <= __y;
+ static_assert(static_cast<int>(std::numeric_limits<decltype(__y_)>::max()) == static_cast<int>(max()));
+ return static_cast<int>(min()) <= __y_;
}
} // namespace chrono
diff --git a/libcxx/include/__chrono/year_month.h b/libcxx/include/__chrono/year_month.h
index 51b19caa1124..9f1e65c8c83d 100644
--- a/libcxx/include/__chrono/year_month.h
+++ b/libcxx/include/__chrono/year_month.h
@@ -14,6 +14,7 @@
#include <__chrono/month.h>
#include <__chrono/year.h>
#include <__config>
+#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -27,19 +28,19 @@ namespace chrono
{
class year_month {
- chrono::year __y;
- chrono::month __m;
+ chrono::year __y_;
+ chrono::month __m_;
public:
_LIBCPP_HIDE_FROM_ABI year_month() = default;
_LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
- : __y{__yval}, __m{__mval} {}
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
+ : __y_{__yval}, __m_{__mval} {}
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m_ += __dm; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m_ -= __dm; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y_ += __dy; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y_ -= __dy; return *this; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
@@ -52,25 +53,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI 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(); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
-{ return !(__lhs < __rhs); }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
+ if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
+ return __c;
+ return __lhs.month() <=> __rhs.month();
+}
_LIBCPP_HIDE_FROM_ABI constexpr
year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
diff --git a/libcxx/include/__chrono/year_month_day.h b/libcxx/include/__chrono/year_month_day.h
index 957716aab690..b74901470c66 100644
--- a/libcxx/include/__chrono/year_month_day.h
+++ b/libcxx/include/__chrono/year_month_day.h
@@ -20,6 +20,7 @@
#include <__chrono/year.h>
#include <__chrono/year_month.h>
#include <__config>
+#include <compare>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -37,14 +38,14 @@ class year_month_day_last;
class year_month_day {
private:
- chrono::year __y;
- chrono::month __m;
- chrono::day __d;
+ chrono::year __y_;
+ chrono::month __m_;
+ chrono::day __d_;
public:
_LIBCPP_HIDE_FROM_ABI year_month_day() = default;
_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(
const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __y{__yval}, __m{__mval}, __d{__dval} {}
+ : __y_{__yval}, __m_{__mval}, __d_{__dval} {}
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept
: year_month_day(__from_days(__sysd.time_since_epoch())) {}
@@ -56,9 +57,9 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
_LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
@@ -94,9 +95,9 @@ 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 __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]
@@ -109,33 +110,16 @@ _LIBCPP_HIDE_FROM_ABI 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(); }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs == __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI 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();
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
+operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
+ if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
+ return __c;
+ if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
+ return __c;
+ return __lhs.day() <=> __rhs.day();
}
_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return __rhs < __lhs; }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__rhs < __lhs);}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
-{ return !(__lhs < __rhs); }
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
@@ -191,24 +175,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-
class year_month_day_last {
private:
- chrono::year __y;
- chrono::month_day_last __mdl;
+ chrono::year __y_;
+ chrono::month_day_last __mdl_;
public:
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
- : __y{__yval}, __mdl{__mdlval} {}
+ : __y_{__yval}, __mdl_{__mdlval} {}
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl_.month(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl_; }
_LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
_LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __mdl_.ok(); }
};
_LIBCPP_HIDE_FROM_ABI inline constexpr
@@ -221,7 +205,7 @@ chrono::day year_month_day_last::day() const noexcept
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() ?
+ return (month() != February || !__y_.is_leap()) && month().ok() ?
__d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
}
@@ -305,13 +289,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last:
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
- : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+ : __y_{__ymdl.year()}, __m_{__ymdl.month()}, __d_{__ymdl.day()} {}
_LIBCPP_HIDE_FROM_ABI 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();
+ if (!__y_.ok() || !__m_.ok()) return false;
+ return chrono::day{1} <= __d_ && __d_ <= (__y_ / __m_ / last).day();
}
} // namespace chrono
diff --git a/libcxx/include/__chrono/year_month_weekday.h b/libcxx/include/__chrono/year_month_weekday.h
index b69b77152fb1..6604deaf12cd 100644
--- a/libcxx/include/__chrono/year_month_weekday.h
+++ b/libcxx/include/__chrono/year_month_weekday.h
@@ -35,14 +35,14 @@ namespace chrono
{
class year_month_weekday {
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_indexed __wdi;
+ chrono::year __y_;
+ chrono::month __m_;
+ chrono::weekday_indexed __wdi_;
public:
_LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
const chrono::weekday_indexed& __wdival) noexcept
- : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
+ : __y_{__yval}, __m_{__mval}, __wdi_{__wdival} {}
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept
: year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
@@ -52,24 +52,24 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
- _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi.index(); }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi_.weekday(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi_.index(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
_LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept
{
- if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
- if (__wdi.index() <= 4) return true;
+ 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};
+ __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_cast<unsigned>((__y_ / __m_ / last).day());
}
_LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept;
@@ -89,8 +89,8 @@ year_month_weekday year_month_weekday::__from_days(days __d) noexcept
_LIBCPP_HIDE_FROM_ABI 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}))
+ const sys_days __sysd = sys_days(__y_/__m_/1);
+ return (__sysd + (__wdi_.weekday() - chrono::weekday(__sysd) + days{(__wdi_.index()-1)*7}))
.time_since_epoch();
}
@@ -155,25 +155,25 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::o
class year_month_weekday_last {
private:
- chrono::year __y;
- chrono::month __m;
- chrono::weekday_last __wdl;
+ chrono::year __y_;
+ chrono::month __m_;
+ chrono::weekday_last __wdl_;
public:
_LIBCPP_HIDE_FROM_ABI 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} {}
+ : __y_{__yval}, __m_{__mval}, __wdl_{__wdlval} {}
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
_LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
- _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl_.weekday(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
_LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
- _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
+ _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok() && __wdl_.ok(); }
_LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
@@ -182,8 +182,8 @@ public:
_LIBCPP_HIDE_FROM_ABI 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();
+ const sys_days __last = sys_days{__y_/__m_/last};
+ return (__last - (chrono::weekday{__last} - __wdl_.weekday())).time_since_epoch();
}
diff --git a/libcxx/include/__compare/common_comparison_category.h b/libcxx/include/__compare/common_comparison_category.h
index deab171846e2..06c4b28491e3 100644
--- a/libcxx/include/__compare/common_comparison_category.h
+++ b/libcxx/include/__compare/common_comparison_category.h
@@ -11,7 +11,8 @@
#include <__compare/ordering.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_same.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -64,7 +65,7 @@ _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);
+ constexpr _CCC _Cat = __comp_detail::__compute_comp_type(__type_kinds);
if constexpr (_Cat == _None)
return void();
else if constexpr (_Cat == _PartialOrd)
diff --git a/libcxx/include/__compare/compare_partial_order_fallback.h b/libcxx/include/__compare/compare_partial_order_fallback.h
index ba746d6c7d9c..06f03fe7adee 100644
--- a/libcxx/include/__compare/compare_partial_order_fallback.h
+++ b/libcxx/include/__compare/compare_partial_order_fallback.h
@@ -12,9 +12,10 @@
#include <__compare/ordering.h>
#include <__compare/partial_order.h>
#include <__config>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_same.h>
#include <__utility/forward.h>
#include <__utility/priority_tag.h>
-#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
diff --git a/libcxx/include/__compare/compare_strong_order_fallback.h b/libcxx/include/__compare/compare_strong_order_fallback.h
index 312a08ef7e90..869386817a12 100644
--- a/libcxx/include/__compare/compare_strong_order_fallback.h
+++ b/libcxx/include/__compare/compare_strong_order_fallback.h
@@ -12,9 +12,10 @@
#include <__compare/ordering.h>
#include <__compare/strong_order.h>
#include <__config>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_same.h>
#include <__utility/forward.h>
#include <__utility/priority_tag.h>
-#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
diff --git a/libcxx/include/__compare/compare_three_way_result.h b/libcxx/include/__compare/compare_three_way_result.h
index 7b03597ab1c1..8885d7effad1 100644
--- a/libcxx/include/__compare/compare_three_way_result.h
+++ b/libcxx/include/__compare/compare_three_way_result.h
@@ -10,7 +10,8 @@
#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/make_const_lvalue_ref.h>
+#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,9 +26,9 @@ 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()
+ std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void()
)> {
- using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>());
+ using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
};
template<class _Tp, class _Up = _Tp>
diff --git a/libcxx/include/__compare/compare_weak_order_fallback.h b/libcxx/include/__compare/compare_weak_order_fallback.h
index 844d67608703..f434dcb4a31a 100644
--- a/libcxx/include/__compare/compare_weak_order_fallback.h
+++ b/libcxx/include/__compare/compare_weak_order_fallback.h
@@ -12,9 +12,10 @@
#include <__compare/ordering.h>
#include <__compare/weak_order.h>
#include <__config>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_same.h>
#include <__utility/forward.h>
#include <__utility/priority_tag.h>
-#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
diff --git a/libcxx/include/__compare/ordering.h b/libcxx/include/__compare/ordering.h
index 1d466d669eec..ff148abf234f 100644
--- a/libcxx/include/__compare/ordering.h
+++ b/libcxx/include/__compare/ordering.h
@@ -10,7 +10,8 @@
#define _LIBCPP___COMPARE_ORDERING_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_same.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -312,6 +313,12 @@ 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);
+/// [cmp.categories.pre]/1
+/// The types partial_ordering, weak_ordering, and strong_ordering are
+/// collectively termed the comparison category types.
+template <class _Tp>
+concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>;
+
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__compare/partial_order.h b/libcxx/include/__compare/partial_order.h
index 970f01b3f1b0..aee07ebb4280 100644
--- a/libcxx/include/__compare/partial_order.h
+++ b/libcxx/include/__compare/partial_order.h
@@ -13,9 +13,10 @@
#include <__compare/ordering.h>
#include <__compare/weak_order.h>
#include <__config>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_same.h>
#include <__utility/forward.h>
#include <__utility/priority_tag.h>
-#include <type_traits>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [cmp.alg]
namespace __partial_order {
struct __fn {
+ // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
template<class _Tp, class _Up>
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
_LIBCPP_HIDE_FROM_ABI static constexpr auto
@@ -35,6 +37,7 @@ namespace __partial_order {
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))); }
+ // NOLINTEND(libcpp-robust-against-adl)
template<class _Tp, class _Up>
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
diff --git a/libcxx/include/__compare/strong_order.h b/libcxx/include/__compare/strong_order.h
index 67c7b2910bd5..05856c209390 100644
--- a/libcxx/include/__compare/strong_order.h
+++ b/libcxx/include/__compare/strong_order.h
@@ -13,12 +13,13 @@
#include <__compare/compare_three_way.h>
#include <__compare/ordering.h>
#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
#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
@@ -34,6 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [cmp.alg]
namespace __strong_order {
struct __fn {
+ // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
template<class _Tp, class _Up>
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
_LIBCPP_HIDE_FROM_ABI static constexpr auto
@@ -41,6 +43,7 @@ namespace __strong_order {
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))); }
+ // NOLINTEND(libcpp-robust-against-adl)
template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h
index fa8cbda79ba2..7d338987e0d4 100644
--- a/libcxx/include/__compare/synth_three_way.h
+++ b/libcxx/include/__compare/synth_three_way.h
@@ -42,7 +42,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
};
template <class _Tp, class _Up = _Tp>
-using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
+using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
#endif // _LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__compare/three_way_comparable.h b/libcxx/include/__compare/three_way_comparable.h
index b317d750590e..6c98916d858e 100644
--- a/libcxx/include/__compare/three_way_comparable.h
+++ b/libcxx/include/__compare/three_way_comparable.h
@@ -16,7 +16,8 @@
#include <__concepts/same_as.h>
#include <__concepts/totally_ordered.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/make_const_lvalue_ref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__compare/weak_order.h b/libcxx/include/__compare/weak_order.h
index c2fae1a98deb..abb24e3665b5 100644
--- a/libcxx/include/__compare/weak_order.h
+++ b/libcxx/include/__compare/weak_order.h
@@ -13,10 +13,10 @@
#include <__compare/ordering.h>
#include <__compare/strong_order.h>
#include <__config>
+#include <__type_traits/decay.h>
#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
@@ -29,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [cmp.alg]
namespace __weak_order {
struct __fn {
+ // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
template<class _Tp, class _Up>
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
_LIBCPP_HIDE_FROM_ABI static constexpr auto
@@ -36,6 +37,7 @@ namespace __weak_order {
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))); }
+ // NOLINTEND(libcpp-robust-against-adl)
template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
diff --git a/libcxx/include/__concepts/arithmetic.h b/libcxx/include/__concepts/arithmetic.h
index d91570f02b8b..215b52aa0218 100644
--- a/libcxx/include/__concepts/arithmetic.h
+++ b/libcxx/include/__concepts/arithmetic.h
@@ -10,9 +10,11 @@
#define _LIBCPP___CONCEPTS_ARITHMETIC_H
#include <__config>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_signed.h>
#include <__type_traits/is_signed_integer.h>
#include <__type_traits/is_unsigned_integer.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/assignable.h b/libcxx/include/__concepts/assignable.h
index 7f187a39f8f8..91edd400adf6 100644
--- a/libcxx/include/__concepts/assignable.h
+++ b/libcxx/include/__concepts/assignable.h
@@ -12,8 +12,9 @@
#include <__concepts/common_reference_with.h>
#include <__concepts/same_as.h>
#include <__config>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/make_const_lvalue_ref.h>
#include <__utility/forward.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/class_or_enum.h b/libcxx/include/__concepts/class_or_enum.h
index 9fd62ba89243..c4d2f98952c0 100644
--- a/libcxx/include/__concepts/class_or_enum.h
+++ b/libcxx/include/__concepts/class_or_enum.h
@@ -10,7 +10,10 @@
#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_union.h>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,7 +31,7 @@ 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>>;
+concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>;
#endif // _LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__concepts/common_reference_with.h b/libcxx/include/__concepts/common_reference_with.h
index cae2f5bccce0..cc92762d3109 100644
--- a/libcxx/include/__concepts/common_reference_with.h
+++ b/libcxx/include/__concepts/common_reference_with.h
@@ -12,7 +12,7 @@
#include <__concepts/convertible_to.h>
#include <__concepts/same_as.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/common_with.h b/libcxx/include/__concepts/common_with.h
index 1b5f4da4af9a..569a0ee3b769 100644
--- a/libcxx/include/__concepts/common_with.h
+++ b/libcxx/include/__concepts/common_with.h
@@ -12,7 +12,10 @@
#include <__concepts/common_reference_with.h>
#include <__concepts/same_as.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/common_type.h>
+#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,8 +31,8 @@ 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>());
+ static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
+ static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
} &&
common_reference_with<
add_lvalue_reference_t<const _Tp>,
diff --git a/libcxx/include/__concepts/constructible.h b/libcxx/include/__concepts/constructible.h
index aaf515417e4c..1d78eb5fd157 100644
--- a/libcxx/include/__concepts/constructible.h
+++ b/libcxx/include/__concepts/constructible.h
@@ -12,7 +12,7 @@
#include <__concepts/convertible_to.h>
#include <__concepts/destructible.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/convertible_to.h b/libcxx/include/__concepts/convertible_to.h
index 5d9d43710421..2c1d2674100f 100644
--- a/libcxx/include/__concepts/convertible_to.h
+++ b/libcxx/include/__concepts/convertible_to.h
@@ -10,8 +10,8 @@
#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
#include <__config>
+#include <__type_traits/is_convertible.h>
#include <__utility/declval.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -27,7 +27,7 @@ template<class _From, class _To>
concept convertible_to =
is_convertible_v<_From, _To> &&
requires {
- static_cast<_To>(declval<_From>());
+ static_cast<_To>(std::declval<_From>());
};
#endif // _LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__concepts/derived_from.h b/libcxx/include/__concepts/derived_from.h
index 4b2914794735..0d3462df6a6d 100644
--- a/libcxx/include/__concepts/derived_from.h
+++ b/libcxx/include/__concepts/derived_from.h
@@ -10,7 +10,8 @@
#define _LIBCPP___CONCEPTS_DERIVED_FROM_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_convertible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/destructible.h b/libcxx/include/__concepts/destructible.h
index 90a043d314c2..ad3819d5dcfe 100644
--- a/libcxx/include/__concepts/destructible.h
+++ b/libcxx/include/__concepts/destructible.h
@@ -10,7 +10,7 @@
#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_nothrow_destructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/different_from.h b/libcxx/include/__concepts/different_from.h
index 3066372e8683..15fd8f05510b 100644
--- a/libcxx/include/__concepts/different_from.h
+++ b/libcxx/include/__concepts/different_from.h
@@ -11,7 +11,7 @@
#include <__concepts/same_as.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/equality_comparable.h b/libcxx/include/__concepts/equality_comparable.h
index 7c750c5937b5..b865141705f1 100644
--- a/libcxx/include/__concepts/equality_comparable.h
+++ b/libcxx/include/__concepts/equality_comparable.h
@@ -12,7 +12,8 @@
#include <__concepts/boolean_testable.h>
#include <__concepts/common_reference_with.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/make_const_lvalue_ref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/invocable.h b/libcxx/include/__concepts/invocable.h
index d90389e97f3b..ec39b7b817cc 100644
--- a/libcxx/include/__concepts/invocable.h
+++ b/libcxx/include/__concepts/invocable.h
@@ -12,7 +12,6 @@
#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
diff --git a/libcxx/include/__concepts/movable.h b/libcxx/include/__concepts/movable.h
index 639219ed6b48..749b78ad10b8 100644
--- a/libcxx/include/__concepts/movable.h
+++ b/libcxx/include/__concepts/movable.h
@@ -13,7 +13,7 @@
#include <__concepts/constructible.h>
#include <__concepts/swappable.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_object.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/predicate.h b/libcxx/include/__concepts/predicate.h
index cb239752309f..7ae97832642d 100644
--- a/libcxx/include/__concepts/predicate.h
+++ b/libcxx/include/__concepts/predicate.h
@@ -12,7 +12,7 @@
#include <__concepts/boolean_testable.h>
#include <__concepts/invocable.h>
#include <__config>
-#include <type_traits>
+#include <__functional/invoke.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/same_as.h b/libcxx/include/__concepts/same_as.h
index 765490661148..554ebc3b074b 100644
--- a/libcxx/include/__concepts/same_as.h
+++ b/libcxx/include/__concepts/same_as.h
@@ -10,7 +10,7 @@
#define _LIBCPP___CONCEPTS_SAME_AS_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_same.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/swappable.h b/libcxx/include/__concepts/swappable.h
index fef940f21fed..d91a7a1dc3c3 100644
--- a/libcxx/include/__concepts/swappable.h
+++ b/libcxx/include/__concepts/swappable.h
@@ -14,10 +14,15 @@
#include <__concepts/common_reference_with.h>
#include <__concepts/constructible.h>
#include <__config>
+#include <__type_traits/extent.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/exchange.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
+#include <__utility/swap.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__concepts/totally_ordered.h b/libcxx/include/__concepts/totally_ordered.h
index 25347790de07..f12d26b10827 100644
--- a/libcxx/include/__concepts/totally_ordered.h
+++ b/libcxx/include/__concepts/totally_ordered.h
@@ -12,7 +12,8 @@
#include <__concepts/boolean_testable.h>
#include <__concepts/equality_comparable.h>
#include <__config>
-#include <type_traits>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/make_const_lvalue_ref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 8c2f7614af53..b9203e640a3e 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -22,9 +22,22 @@
# pragma GCC system_header
#endif
+#if defined(__apple_build_version__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
+#elif defined(__clang__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+#elif defined(__GNUC__)
+# define _LIBCPP_COMPILER_GCC
+#endif
+
#ifdef __cplusplus
-# define _LIBCPP_VERSION 15000
+// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
+// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 16.0.1 == 16.00.01), _LIBCPP_VERSION is
+// defined to XXYYZZ.
+# define _LIBCPP_VERSION 160000
# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
@@ -47,7 +60,8 @@
# elif __cplusplus <= 202002L
# define _LIBCPP_STD_VER 20
# else
-# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
+// Expected release year of the next C++ standard
+# define _LIBCPP_STD_VER 23
# endif
# endif // _LIBCPP_STD_VER
@@ -155,7 +169,7 @@
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
# endif
-# define _LIBCPP_TOSTRING2(x) # x
+# define _LIBCPP_TOSTRING2(x) #x
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
# if __cplusplus < 201103L
@@ -182,6 +196,10 @@
# define __has_cpp_attribute(__x) 0
# endif
+# ifndef __has_constexpr_builtin
+# define __has_constexpr_builtin(x) 0
+# endif
+
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
# ifndef __is_identifier
@@ -198,28 +216,10 @@
# define __has_include(...) 0
# endif
-# if defined(__apple_build_version__)
-# define _LIBCPP_COMPILER_CLANG_BASED
-# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
-# elif defined(__clang__)
-# define _LIBCPP_COMPILER_CLANG_BASED
-# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-# elif defined(__GNUC__)
-# define _LIBCPP_COMPILER_GCC
-# elif defined(_MSC_VER)
-# define _LIBCPP_COMPILER_MSVC
-# endif
-
# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
# endif
-# ifdef _LIBCPP_COMPILER_MSVC
-# error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
-changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
-If there are users of this configuration we are happy to provide support.
-# 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,
@@ -253,7 +253,6 @@ If there are users of this configuration we are happy to provide support.
// easier to grep for target specific flags once the feature is complete.
# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
# endif
// Need to detect which libc we're using if we're on Linux.
@@ -418,17 +417,21 @@ If there are users of this configuration we are happy to provide support.
# define _LIBCPP_NORETURN [[noreturn]]
# define _NOEXCEPT noexcept
# define _NOEXCEPT_(x) noexcept(x)
+# define _LIBCPP_CONSTEXPR constexpr
# else
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
# define _ALIGNAS(x) __attribute__((__aligned__(x)))
-# define _LIBCPP_NORETURN __attribute__((noreturn))
+# define _LIBCPP_NORETURN __attribute__((__noreturn__))
# define _LIBCPP_HAS_NO_NOEXCEPT
# define nullptr __nullptr
# define _NOEXCEPT throw()
# define _NOEXCEPT_(x)
+# define static_assert(...) _Static_assert(__VA_ARGS__)
+# define decltype(...) __decltype(__VA_ARGS__)
+# define _LIBCPP_CONSTEXPR
typedef __char16_t char16_t;
typedef __char32_t char32_t;
@@ -487,27 +490,7 @@ typedef __char32_t char32_t;
# 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_NORETURN __declspec(noreturn)
-
-# define _LIBCPP_WEAK
-
-# define _LIBCPP_HAS_NO_ASAN
-
-# define _LIBCPP_ALWAYS_INLINE __forceinline
-
-# define _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
-# define _LIBCPP_DISABLE_EXTENSION_WARNING
-
-# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
+# endif // _LIBCPP_COMPILER_[CLANG|GCC]
# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
@@ -627,6 +610,15 @@ typedef __char32_t char32_t;
// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
//
+// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
+// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
+// name of a virtual function is part of its ABI, since some architectures like arm64e can sign
+// the virtual function pointer in the vtable based on the mangled name of the function. Since
+// we use an ABI tag that changes with each released version, the mangled name of the virtual
+// function would change, which is incorrect. Note that it doesn't make much sense to change
+// the implementation of a virtual function in an ABI-incompatible way in the first place,
+// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
+//
// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
@@ -637,6 +629,7 @@ typedef __char32_t char32_t;
# else
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
# endif
+# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
# ifdef _LIBCPP_BUILDING_LIBRARY
# if _LIBCPP_ABI_VERSION > 1
@@ -680,31 +673,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# 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
-# ifdef __GNUC__
+# if __has_attribute(__malloc__)
# 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))
+# if __has_attribute(__using_if_exists__)
+# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
# else
# define _LIBCPP_USING_IF_EXISTS
# endif
@@ -752,6 +734,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
# endif
+// It is not yet possible to use aligned_alloc() on all Apple platforms since
+// 10.15 was the first version to ship an implementation of aligned_alloc().
+# if defined(__APPLE__)
+# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
+# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
+# endif
+# elif defined(__ANDROID__) && __ANDROID_API__ < 28
+// Android only provides aligned_alloc when targeting API 28 or higher.
+# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
+# endif
+
# if defined(__APPLE__) || defined(__FreeBSD__)
# define _LIBCPP_HAS_DEFAULTRUNELOCALE
# endif
@@ -771,7 +765,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if __has_attribute(deprecated)
# define _LIBCPP_DEPRECATED __attribute__((deprecated))
-# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
+# define _LIBCPP_DEPRECATED_(m) __attribute__((deprecated(m)))
# elif _LIBCPP_STD_VER > 11
# define _LIBCPP_DEPRECATED [[deprecated]]
# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
@@ -808,6 +802,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_DEPRECATED_IN_CXX20
# endif
+#if _LIBCPP_STD_VER >= 23
+# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX23
+#endif
+
# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
# else
@@ -832,27 +832,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# endif
# if _LIBCPP_STD_VER > 11
-# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
+# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
# else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX11
+# define _LIBCPP_CONSTEXPR_SINCE_CXX14
# endif
# if _LIBCPP_STD_VER > 14
-# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
# else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX14
+# define _LIBCPP_CONSTEXPR_SINCE_CXX17
# endif
# if _LIBCPP_STD_VER > 17
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
# else
-# define _LIBCPP_CONSTEXPR_AFTER_CXX17
+# define _LIBCPP_CONSTEXPR_SINCE_CXX20
# endif
-# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
+# if _LIBCPP_STD_VER > 20
+# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
+# else
+# define _LIBCPP_CONSTEXPR_SINCE_CXX23
+# endif
+
+# if __has_cpp_attribute(nodiscard)
# 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
@@ -862,19 +866,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
// _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)
+# if !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))
+# if _LIBCPP_STD_VER > 17 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
# else
# define _LIBCPP_NODISCARD_AFTER_CXX17
# endif
-# if __has_attribute(no_destroy)
+# if __has_attribute(__no_destroy__)
# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
# else
# define _LIBCPP_NO_DESTROY
@@ -1036,18 +1040,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# if _LIBCPP_STD_VER > 17
# define _LIBCPP_CONSTINIT constinit
-# elif __has_attribute(require_constant_initialization)
+# elif __has_attribute(__require_constant_initialization__)
# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
# else
# define _LIBCPP_CONSTINIT
# 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")))
+# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
+# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
# 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
@@ -1059,6 +1061,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_FALLTHROUGH() ((void)0)
# endif
+# if __has_cpp_attribute(_Clang::__lifetimebound__)
+# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
+# else
+# define _LIBCPP_LIFETIMEBOUND
+# endif
+
# if __has_attribute(__nodebug__)
# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
# else
@@ -1087,7 +1095,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
# endif
-# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
# else
# define _LIBCPP_DECLSPEC_EMPTY_BASES
@@ -1110,10 +1118,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# 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
-
# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
@@ -1145,19 +1149,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# 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
+# if __has_attribute(__init_priority__)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
# else
# define _LIBCPP_INIT_PRIORITY_MAX
# endif
-# if defined(__GNUC__) || defined(__clang__)
+# if __has_attribute(__format__)
// 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) \
@@ -1219,6 +1217,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_PACKED
# endif
+// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
+// functions is gradually being added to existing C libraries. The conditions
+// below check for known C library versions and conditions under which these
+// functions are declared by the C library.
+# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
+// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
+// __cpp_char8_t is defined or if C2X extensions are enabled. Unfortunately,
+// determining the latter depends on internal GNU libc details. If the
+// __cpp_char8_t feature test macro is not defined, then a char8_t typedef
+// will be declared as well.
+# if defined(_LIBCPP_GLIBC_PREREQ) && defined(__GLIBC_USE)
+# if _LIBCPP_GLIBC_PREREQ(2, 36) && (defined(__cpp_char8_t) || __GLIBC_USE(ISOC2X))
+# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
+# endif
+# endif
+
+// There are a handful of public standard library types that are intended to
+// support CTAD but don't need any explicit deduction guides to do so. This
+// macro is used to mark them as such, which suppresses the
+// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
+// with these classes.
+#if _LIBCPP_STD_VER >= 17
+# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
+ template <class ..._Tag> \
+ _ClassName(typename _Tag::__allow_ctad...) -> _ClassName<_Tag...>
+#else
+# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
+#endif
+
#endif // __cplusplus
#endif // _LIBCPP___CONFIG
diff --git a/libcxx/include/__coroutine/coroutine_handle.h b/libcxx/include/__coroutine/coroutine_handle.h
index 4bf323789217..0a6cc1cab690 100644
--- a/libcxx/include/__coroutine/coroutine_handle.h
+++ b/libcxx/include/__coroutine/coroutine_handle.h
@@ -13,14 +13,15 @@
#include <__config>
#include <__functional/hash.h>
#include <__memory/addressof.h>
+#include <__type_traits/remove_cv.h>
#include <compare>
-#include <type_traits>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -115,7 +116,7 @@ public:
_LIBCPP_HIDE_FROM_ABI
static coroutine_handle from_promise(_Promise& __promise) {
- using _RawPromise = typename remove_cv<_Promise>::type;
+ using _RawPromise = __remove_cv_t<_Promise>;
coroutine_handle __tmp;
__tmp.__handle_ =
__builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
@@ -197,6 +198,6 @@ struct hash<coroutine_handle<_Tp>> {
_LIBCPP_END_NAMESPACE_STD
-#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#endif // __LIBCPP_STD_VER > 17
#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
diff --git a/libcxx/include/__coroutine/coroutine_traits.h b/libcxx/include/__coroutine/coroutine_traits.h
index 0a5229b45945..d513075098c6 100644
--- a/libcxx/include/__coroutine/coroutine_traits.h
+++ b/libcxx/include/__coroutine/coroutine_traits.h
@@ -10,13 +10,13 @@
#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/void_t.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)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -35,7 +35,7 @@ struct __coroutine_traits_sfinae {};
template <class _Tp>
struct __coroutine_traits_sfinae<
- _Tp, typename __void_t<typename _Tp::promise_type>::type>
+ _Tp, __void_t<typename _Tp::promise_type> >
{
using promise_type = typename _Tp::promise_type;
};
@@ -48,6 +48,6 @@ struct coroutine_traits
_LIBCPP_END_NAMESPACE_STD
-#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#endif // __LIBCPP_STD_VER > 17
#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
diff --git a/libcxx/include/__coroutine/noop_coroutine_handle.h b/libcxx/include/__coroutine/noop_coroutine_handle.h
index 7a2c672057cb..299304794ccb 100644
--- a/libcxx/include/__coroutine/noop_coroutine_handle.h
+++ b/libcxx/include/__coroutine/noop_coroutine_handle.h
@@ -16,7 +16,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -107,6 +107,6 @@ noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle()
_LIBCPP_END_NAMESPACE_STD
-#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#endif // __LIBCPP_STD_VER > 17
#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
diff --git a/libcxx/include/__coroutine/trivial_awaitables.h b/libcxx/include/__coroutine/trivial_awaitables.h
index 31399ab29a00..bbbae7a47f23 100644
--- a/libcxx/include/__coroutine/trivial_awaitables.h
+++ b/libcxx/include/__coroutine/trivial_awaitables.h
@@ -16,7 +16,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -41,6 +41,6 @@ struct suspend_always {
_LIBCPP_END_NAMESPACE_STD
-#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
+#endif // __LIBCPP_STD_VER > 17
#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
diff --git a/libcxx/include/__debug b/libcxx/include/__debug
index 59e85cb7d1bc..140cc9142a82 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -12,22 +12,21 @@
#include <__assert>
#include <__config>
+#include <__type_traits/is_constant_evaluated.h>
#include <cstddef>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
-#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
-# error "Enabling the debug mode now requires having configured the library with support for the debug mode"
-#endif
-
#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#endif
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING)
+# define _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
+#endif
+
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
#else
@@ -87,10 +86,10 @@ struct _C_node
explicit _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;
+ bool __dereferenceable(const void*) const override;
+ bool __decrementable(const void*) const override;
+ bool __addable(const void*, ptrdiff_t) const override;
+ bool __subscriptable(const void*, ptrdiff_t) const override;
};
template <class _Cont>
@@ -212,7 +211,7 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_insert_c(_Tp* __c) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_c(__c);
@@ -222,7 +221,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
}
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_insert_i(_Tp* __i) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_i(__i);
@@ -232,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
}
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_erase_c(_Tp* __c) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__erase_c(__c);
@@ -242,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase
}
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->swap(__lhs, __rhs);
@@ -253,7 +252,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(
}
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_invalidate_all(_Tp* __c) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__invalidate_all(__c);
diff --git a/libcxx/include/__debug_utils/randomize_range.h b/libcxx/include/__debug_utils/randomize_range.h
index 9843709019d4..dce61923bc9c 100644
--- a/libcxx/include/__debug_utils/randomize_range.h
+++ b/libcxx/include/__debug_utils/randomize_range.h
@@ -23,7 +23,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Iterator, class _Sentinel>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
void __debug_randomize_range(_Iterator __first, _Sentinel __last) {
#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
# ifdef _LIBCPP_CXX03_LANG
diff --git a/libcxx/include/__expected/bad_expected_access.h b/libcxx/include/__expected/bad_expected_access.h
new file mode 100644
index 000000000000..361eab4b6018
--- /dev/null
+++ b/libcxx/include/__expected/bad_expected_access.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
+#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
+
+#include <__config>
+#include <__utility/move.h>
+
+#include <exception>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Err>
+class bad_expected_access;
+
+template <>
+class bad_expected_access<void> : public exception {
+protected:
+ _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default;
+ _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) = default;
+ _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) = default;
+ _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) = default;
+ _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) = default;
+ ~bad_expected_access() override = default;
+
+public:
+ // The way this has been designed (by using a class template below) means that we'll already
+ // have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch
+ // of work to do. So it is not worth hiding the <void> specialization in the dylib, given that
+ // it adds deployment target restrictions.
+ const char* what() const noexcept override { return "bad access to std::expected"; }
+};
+
+template <class _Err>
+class bad_expected_access : public bad_expected_access<void> {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {}
+
+ _LIBCPP_HIDE_FROM_ABI _Err& error() & noexcept { return __unex_; }
+ _LIBCPP_HIDE_FROM_ABI const _Err& error() const& noexcept { return __unex_; }
+ _LIBCPP_HIDE_FROM_ABI _Err&& error() && noexcept { return std::move(__unex_); }
+ _LIBCPP_HIDE_FROM_ABI const _Err&& error() const&& noexcept { return std::move(__unex_); }
+
+private:
+ _Err __unex_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h
new file mode 100644
index 000000000000..e1f590c65efe
--- /dev/null
+++ b/libcxx/include/__expected/expected.h
@@ -0,0 +1,973 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___EXPECTED_EXPECTED_H
+#define _LIBCPP___EXPECTED_EXPECTED_H
+
+#include <__assert>
+#include <__config>
+#include <__expected/bad_expected_access.h>
+#include <__expected/unexpect.h>
+#include <__expected/unexpected.h>
+#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_copy_assignable.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_copy_assignable.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/is_trivially_copy_constructible.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__type_traits/is_trivially_move_constructible.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/lazy.h>
+#include <__type_traits/negation.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/exception_guard.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <cstdlib> // for std::abort
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __expected {
+
+template <class _Err, class _Arg>
+_LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) {
+# ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_expected_access<_Err>(std::forward<_Arg>(__arg));
+# else
+ (void)__arg;
+ std::abort();
+# endif
+}
+
+} // namespace __expected
+
+template <class _Tp, class _Err>
+class expected {
+ static_assert(
+ !is_reference_v<_Tp> &&
+ !is_function_v<_Tp> &&
+ !is_same_v<remove_cv_t<_Tp>, in_place_t> &&
+ !is_same_v<remove_cv_t<_Tp>, unexpect_t> &&
+ !__is_std_unexpected<remove_cv_t<_Tp>>::value &&
+ __valid_std_unexpected<_Err>::value
+ ,
+ "[expected.object.general] A program that instantiates the definition of template expected<T, E> for a "
+ "reference type, a function type, or for possibly cv-qualified types in_place_t, unexpect_t, or a "
+ "specialization of unexpected for the T parameter is ill-formed. A program that instantiates the "
+ "definition of the template expected<T, E> with a type for the E parameter that is not a valid "
+ "template argument for unexpected is ill-formed.");
+
+ template <class _Up, class _OtherErr>
+ friend class expected;
+
+public:
+ using value_type = _Tp;
+ using error_type = _Err;
+ using unexpected_type = unexpected<_Err>;
+
+ template <class _Up>
+ using rebind = expected<_Up, error_type>;
+
+ // [expected.object.ctor], constructors
+ _LIBCPP_HIDE_FROM_ABI constexpr expected()
+ noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened
+ requires is_default_constructible_v<_Tp>
+ : __has_val_(true) {
+ std::construct_at(std::addressof(__union_.__val_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&)
+ requires(is_copy_constructible_v<_Tp> &&
+ is_copy_constructible_v<_Err> &&
+ is_trivially_copy_constructible_v<_Tp> &&
+ is_trivially_copy_constructible_v<_Err>)
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __other)
+ noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened
+ requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> &&
+ !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>))
+ : __has_val_(__other.__has_val_) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_);
+ } else {
+ std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_);
+ }
+ }
+
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&)
+ requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err>
+ && is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __other)
+ noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>)
+ requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> &&
+ !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>))
+ : __has_val_(__other.__has_val_) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_));
+ } else {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_));
+ }
+ }
+
+private:
+ template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>
+ using __can_convert =
+ _And< is_constructible<_Tp, _UfQual>,
+ is_constructible<_Err, _OtherErrQual>,
+ _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,
+ _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,
+ _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,
+ _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,
+ _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,
+ _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>,
+ _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
+ _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;
+
+
+public:
+ template <class _Up, class _OtherErr>
+ requires __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _Up&, _Tp> ||
+ !is_convertible_v<const _OtherErr&, _Err>)
+ expected(const expected<_Up, _OtherErr>& __other)
+ noexcept(is_nothrow_constructible_v<_Tp, const _Up&> &&
+ is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
+ : __has_val_(__other.__has_val_) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_);
+ } else {
+ std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_);
+ }
+ }
+
+ template <class _Up, class _OtherErr>
+ requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>)
+ expected(expected<_Up, _OtherErr>&& __other)
+ noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
+ : __has_val_(__other.__has_val_) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_));
+ } else {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_));
+ }
+ }
+
+ template <class _Up = _Tp>
+ requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> &&
+ !__is_std_unexpected<remove_cvref_t<_Up>>::value && is_constructible_v<_Tp, _Up>)
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>)
+ expected(_Up&& __u)
+ noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened
+ : __has_val_(true) {
+ std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u));
+ }
+
+
+ template <class _OtherErr>
+ requires is_constructible_v<_Err, const _OtherErr&>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
+ expected(const unexpected<_OtherErr>& __unex)
+ noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), __unex.error());
+ }
+
+ template <class _OtherErr>
+ requires is_constructible_v<_Err, _OtherErr>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
+ expected(unexpected<_OtherErr>&& __unex)
+ noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error()));
+ }
+
+ template <class... _Args>
+ requires is_constructible_v<_Tp, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened
+ : __has_val_(true) {
+ std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...);
+ }
+
+ template <class _Up, class... _Args>
+ requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... >
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit
+ expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened
+ : __has_val_(true) {
+ std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args>
+ requires is_constructible_v<_Err, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...);
+ }
+
+ template <class _Up, class... _Args>
+ requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... >
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit
+ expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...);
+ }
+
+ // [expected.object.dtor], destructor
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
+ requires(is_trivially_destructible_v<_Tp> && is_trivially_destructible_v<_Err>)
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
+ requires(!is_trivially_destructible_v<_Tp> || !is_trivially_destructible_v<_Err>)
+ {
+ if (__has_val_) {
+ std::destroy_at(std::addressof(__union_.__val_));
+ } else {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ }
+ }
+
+private:
+ template <class _T1, class _T2, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI static constexpr void __reinit_expected(_T1& __newval, _T2& __oldval, _Args&&... __args) {
+ if constexpr (is_nothrow_constructible_v<_T1, _Args...>) {
+ std::destroy_at(std::addressof(__oldval));
+ std::construct_at(std::addressof(__newval), std::forward<_Args>(__args)...);
+ } else if constexpr (is_nothrow_move_constructible_v<_T1>) {
+ _T1 __tmp(std::forward<_Args>(__args)...);
+ std::destroy_at(std::addressof(__oldval));
+ std::construct_at(std::addressof(__newval), std::move(__tmp));
+ } else {
+ static_assert(
+ is_nothrow_move_constructible_v<_T2>,
+ "To provide strong exception guarantee, T2 has to satisfy `is_nothrow_move_constructible_v` so that it can "
+ "be reverted to the previous state in case an exception is thrown during the assignment.");
+ _T2 __tmp(std::move(__oldval));
+ std::destroy_at(std::addressof(__oldval));
+ __exception_guard __trans([&] { std::construct_at(std::addressof(__oldval), std::move(__tmp)); });
+ std::construct_at(std::addressof(__newval), std::forward<_Args>(__args)...);
+ __trans.__complete();
+ }
+ }
+
+public:
+ // [expected.object.assign], assignment
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs)
+ noexcept(is_nothrow_copy_assignable_v<_Tp> &&
+ is_nothrow_copy_constructible_v<_Tp> &&
+ is_nothrow_copy_assignable_v<_Err> &&
+ is_nothrow_copy_constructible_v<_Err>) // strengthened
+ requires(is_copy_assignable_v<_Tp> &&
+ is_copy_constructible_v<_Tp> &&
+ is_copy_assignable_v<_Err> &&
+ is_copy_constructible_v<_Err> &&
+ (is_nothrow_move_constructible_v<_Tp> ||
+ is_nothrow_move_constructible_v<_Err>))
+ {
+ if (__has_val_ && __rhs.__has_val_) {
+ __union_.__val_ = __rhs.__union_.__val_;
+ } else if (__has_val_) {
+ __reinit_expected(__union_.__unex_, __union_.__val_, __rhs.__union_.__unex_);
+ } else if (__rhs.__has_val_) {
+ __reinit_expected(__union_.__val_, __union_.__unex_, __rhs.__union_.__val_);
+ } else {
+ __union_.__unex_ = __rhs.__union_.__unex_;
+ }
+ // note: only reached if no exception+rollback was done inside __reinit_expected
+ __has_val_ = __rhs.__has_val_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&& __rhs)
+ noexcept(is_nothrow_move_assignable_v<_Tp> &&
+ is_nothrow_move_constructible_v<_Tp> &&
+ is_nothrow_move_assignable_v<_Err> &&
+ is_nothrow_move_constructible_v<_Err>)
+ requires(is_move_constructible_v<_Tp> &&
+ is_move_assignable_v<_Tp> &&
+ is_move_constructible_v<_Err> &&
+ is_move_assignable_v<_Err> &&
+ (is_nothrow_move_constructible_v<_Tp> ||
+ is_nothrow_move_constructible_v<_Err>))
+ {
+ if (__has_val_ && __rhs.__has_val_) {
+ __union_.__val_ = std::move(__rhs.__union_.__val_);
+ } else if (__has_val_) {
+ __reinit_expected(__union_.__unex_, __union_.__val_, std::move(__rhs.__union_.__unex_));
+ } else if (__rhs.__has_val_) {
+ __reinit_expected(__union_.__val_, __union_.__unex_, std::move(__rhs.__union_.__val_));
+ } else {
+ __union_.__unex_ = std::move(__rhs.__union_.__unex_);
+ }
+ // note: only reached if no exception+rollback was done inside __reinit_expected
+ __has_val_ = __rhs.__has_val_;
+ return *this;
+ }
+
+ template <class _Up = _Tp>
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(_Up&& __v)
+ requires(!is_same_v<expected, remove_cvref_t<_Up>> &&
+ !__is_std_unexpected<remove_cvref_t<_Up>>::value &&
+ is_constructible_v<_Tp, _Up> &&
+ is_assignable_v<_Tp&, _Up> &&
+ (is_nothrow_constructible_v<_Tp, _Up> ||
+ is_nothrow_move_constructible_v<_Tp> ||
+ is_nothrow_move_constructible_v<_Err>))
+ {
+ if (__has_val_) {
+ __union_.__val_ = std::forward<_Up>(__v);
+ } else {
+ __reinit_expected(__union_.__val_, __union_.__unex_, std::forward<_Up>(__v));
+ __has_val_ = true;
+ }
+ return *this;
+ }
+
+private:
+ template <class _OtherErrQual>
+ static constexpr bool __can_assign_from_unexpected =
+ _And< is_constructible<_Err, _OtherErrQual>,
+ is_assignable<_Err&, _OtherErrQual>,
+ _Lazy<_Or,
+ is_nothrow_constructible<_Err, _OtherErrQual>,
+ is_nothrow_move_constructible<_Tp>,
+ is_nothrow_move_constructible<_Err>> >::value;
+
+public:
+ template <class _OtherErr>
+ requires(__can_assign_from_unexpected<const _OtherErr&>)
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const unexpected<_OtherErr>& __un) {
+ if (__has_val_) {
+ __reinit_expected(__union_.__unex_, __union_.__val_, __un.error());
+ __has_val_ = false;
+ } else {
+ __union_.__unex_ = __un.error();
+ }
+ return *this;
+ }
+
+ template <class _OtherErr>
+ requires(__can_assign_from_unexpected<_OtherErr>)
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(unexpected<_OtherErr>&& __un) {
+ if (__has_val_) {
+ __reinit_expected(__union_.__unex_, __union_.__val_, std::move(__un.error()));
+ __has_val_ = false;
+ } else {
+ __union_.__unex_ = std::move(__un.error());
+ }
+ return *this;
+ }
+
+ template <class... _Args>
+ requires is_nothrow_constructible_v<_Tp, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(_Args&&... __args) noexcept {
+ if (__has_val_) {
+ std::destroy_at(std::addressof(__union_.__val_));
+ } else {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ __has_val_ = true;
+ }
+ return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...);
+ }
+
+ template <class _Up, class... _Args>
+ requires is_nothrow_constructible_v< _Tp, initializer_list<_Up>&, _Args... >
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept {
+ if (__has_val_) {
+ std::destroy_at(std::addressof(__union_.__val_));
+ } else {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ __has_val_ = true;
+ }
+ return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
+ }
+
+
+public:
+ // [expected.object.swap], swap
+ _LIBCPP_HIDE_FROM_ABI constexpr void swap(expected& __rhs)
+ noexcept(is_nothrow_move_constructible_v<_Tp> &&
+ is_nothrow_swappable_v<_Tp> &&
+ is_nothrow_move_constructible_v<_Err> &&
+ is_nothrow_swappable_v<_Err>)
+ requires(is_swappable_v<_Tp> &&
+ is_swappable_v<_Err> &&
+ is_move_constructible_v<_Tp> &&
+ is_move_constructible_v<_Err> &&
+ (is_nothrow_move_constructible_v<_Tp> ||
+ is_nothrow_move_constructible_v<_Err>))
+ {
+ auto __swap_val_unex_impl = [&](expected& __with_val, expected& __with_err) {
+ if constexpr (is_nothrow_move_constructible_v<_Err>) {
+ _Err __tmp(std::move(__with_err.__union_.__unex_));
+ std::destroy_at(std::addressof(__with_err.__union_.__unex_));
+ __exception_guard __trans([&] {
+ std::construct_at(std::addressof(__with_err.__union_.__unex_), std::move(__tmp));
+ });
+ std::construct_at(std::addressof(__with_err.__union_.__val_), std::move(__with_val.__union_.__val_));
+ __trans.__complete();
+ std::destroy_at(std::addressof(__with_val.__union_.__val_));
+ std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__tmp));
+ } else {
+ static_assert(is_nothrow_move_constructible_v<_Tp>,
+ "To provide strong exception guarantee, Tp has to satisfy `is_nothrow_move_constructible_v` so "
+ "that it can be reverted to the previous state in case an exception is thrown during swap.");
+ _Tp __tmp(std::move(__with_val.__union_.__val_));
+ std::destroy_at(std::addressof(__with_val.__union_.__val_));
+ __exception_guard __trans([&] {
+ std::construct_at(std::addressof(__with_val.__union_.__val_), std::move(__tmp));
+ });
+ std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__with_err.__union_.__unex_));
+ __trans.__complete();
+ std::destroy_at(std::addressof(__with_err.__union_.__unex_));
+ std::construct_at(std::addressof(__with_err.__union_.__val_), std::move(__tmp));
+ }
+ __with_val.__has_val_ = false;
+ __with_err.__has_val_ = true;
+ };
+
+ if (__has_val_) {
+ if (__rhs.__has_val_) {
+ using std::swap;
+ swap(__union_.__val_, __rhs.__union_.__val_);
+ } else {
+ __swap_val_unex_impl(*this, __rhs);
+ }
+ } else {
+ if (__rhs.__has_val_) {
+ __swap_val_unex_impl(__rhs, *this);
+ } else {
+ using std::swap;
+ swap(__union_.__unex_, __rhs.__union_.__unex_);
+ }
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(expected& __x, expected& __y)
+ noexcept(noexcept(__x.swap(__y)))
+ requires requires { __x.swap(__y); }
+ {
+ __x.swap(__y);
+ }
+
+ // [expected.object.obs], observers
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* operator->() const noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator-> requires the expected to contain a value");
+ return std::addressof(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator->() noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator-> requires the expected to contain a value");
+ return std::addressof(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
+ return __union_.__val_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
+ return __union_.__val_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
+ return std::move(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
+ return std::move(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __has_val_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __has_val_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& value() const& {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
+ }
+ return __union_.__val_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
+ }
+ return __union_.__val_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& value() const&& {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
+ }
+ return std::move(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
+ }
+ return std::move(__union_.__val_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return __union_.__unex_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return __union_.__unex_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return std::move(__union_.__unex_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return std::move(__union_.__unex_);
+ }
+
+ template <class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& {
+ static_assert(is_copy_constructible_v<_Tp>, "value_type has to be copy constructible");
+ static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type");
+ return __has_val_ ? __union_.__val_ : static_cast<_Tp>(std::forward<_Up>(__v));
+ }
+
+ template <class _Up>
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && {
+ static_assert(is_move_constructible_v<_Tp>, "value_type has to be move constructible");
+ static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type");
+ return __has_val_ ? std::move(__union_.__val_) : static_cast<_Tp>(std::forward<_Up>(__v));
+ }
+
+ // [expected.object.eq], equality operators
+ template <class _T2, class _E2>
+ requires(!is_void_v<_T2>)
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
+ if (__x.__has_val_ != __y.__has_val_) {
+ return false;
+ } else {
+ if (__x.__has_val_) {
+ return __x.__union_.__val_ == __y.__union_.__val_;
+ } else {
+ return __x.__union_.__unex_ == __y.__union_.__unex_;
+ }
+ }
+ }
+
+ template <class _T2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v) {
+ return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);
+ }
+
+ template <class _E2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e) {
+ return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());
+ }
+
+private:
+ struct __empty_t {};
+ // use named union because [[no_unique_address]] cannot be applied to an unnamed union
+ _LIBCPP_NO_UNIQUE_ADDRESS union __union_t {
+ _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
+ requires(is_trivially_destructible_v<_Tp> && is_trivially_destructible_v<_Err>)
+ = default;
+
+ // the expected's destructor handles this
+ _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
+ requires(!is_trivially_destructible_v<_Tp> || !is_trivially_destructible_v<_Err>)
+ {}
+
+ _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Tp __val_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Err __unex_;
+ } __union_;
+
+ bool __has_val_;
+};
+
+template <class _Tp, class _Err>
+ requires is_void_v<_Tp>
+class expected<_Tp, _Err> {
+ static_assert(__valid_std_unexpected<_Err>::value,
+ "[expected.void.general] A program that instantiates expected<T, E> with a E that is not a "
+ "valid argument for unexpected<E> is ill-formed");
+
+ template <class, class>
+ friend class expected;
+
+ template <class _Up, class _OtherErr, class _OtherErrQual>
+ using __can_convert =
+ _And< is_void<_Up>,
+ is_constructible<_Err, _OtherErrQual>,
+ _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
+ _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
+ _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;
+
+public:
+ using value_type = _Tp;
+ using error_type = _Err;
+ using unexpected_type = unexpected<_Err>;
+
+ template <class _Up>
+ using rebind = expected<_Up, error_type>;
+
+ // [expected.void.ctor], constructors
+ _LIBCPP_HIDE_FROM_ABI constexpr expected() noexcept : __has_val_(true) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&)
+ requires(is_copy_constructible_v<_Err> && is_trivially_copy_constructible_v<_Err>)
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs)
+ noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened
+ requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>)
+ : __has_val_(__rhs.__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&)
+ requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>)
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs)
+ noexcept(is_nothrow_move_constructible_v<_Err>)
+ requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>)
+ : __has_val_(__rhs.__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
+ }
+ }
+
+ template <class _Up, class _OtherErr>
+ requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
+ expected(const expected<_Up, _OtherErr>& __rhs)
+ noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
+ : __has_val_(__rhs.__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
+ }
+ }
+
+ template <class _Up, class _OtherErr>
+ requires __can_convert<_Up, _OtherErr, _OtherErr>::value
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
+ expected(expected<_Up, _OtherErr>&& __rhs)
+ noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
+ : __has_val_(__rhs.__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
+ }
+ }
+
+ template <class _OtherErr>
+ requires is_constructible_v<_Err, const _OtherErr&>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
+ expected(const unexpected<_OtherErr>& __unex)
+ noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), __unex.error());
+ }
+
+ template <class _OtherErr>
+ requires is_constructible_v<_Err, _OtherErr>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
+ expected(unexpected<_OtherErr>&& __unex)
+ noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error()));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {}
+
+ template <class... _Args>
+ requires is_constructible_v<_Err, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...);
+ }
+
+ template <class _Up, class... _Args>
+ requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... >
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
+ noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
+ : __has_val_(false) {
+ std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...);
+ }
+
+ // [expected.void.dtor], destructor
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
+ requires is_trivially_destructible_v<_Err>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
+ requires(!is_trivially_destructible_v<_Err>)
+ {
+ if (!__has_val_) {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ }
+ }
+
+ // [expected.void.assign], assignment
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs)
+ noexcept(is_nothrow_copy_assignable_v<_Err> && is_nothrow_copy_constructible_v<_Err>) // strengthened
+ requires(is_copy_assignable_v<_Err> && is_copy_constructible_v<_Err>)
+ {
+ if (__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
+ __has_val_ = false;
+ }
+ } else {
+ if (__rhs.__has_val_) {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ __has_val_ = true;
+ } else {
+ __union_.__unex_ = __rhs.__union_.__unex_;
+ }
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&& __rhs)
+ noexcept(is_nothrow_move_assignable_v<_Err> &&
+ is_nothrow_move_constructible_v<_Err>)
+ requires(is_move_assignable_v<_Err> &&
+ is_move_constructible_v<_Err>)
+ {
+ if (__has_val_) {
+ if (!__rhs.__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
+ __has_val_ = false;
+ }
+ } else {
+ if (__rhs.__has_val_) {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ __has_val_ = true;
+ } else {
+ __union_.__unex_ = std::move(__rhs.__union_.__unex_);
+ }
+ }
+ return *this;
+ }
+
+ template <class _OtherErr>
+ requires(is_constructible_v<_Err, const _OtherErr&> && is_assignable_v<_Err&, const _OtherErr&>)
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const unexpected<_OtherErr>& __un) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), __un.error());
+ __has_val_ = false;
+ } else {
+ __union_.__unex_ = __un.error();
+ }
+ return *this;
+ }
+
+ template <class _OtherErr>
+ requires(is_constructible_v<_Err, _OtherErr> && is_assignable_v<_Err&, _OtherErr>)
+ _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(unexpected<_OtherErr>&& __un) {
+ if (__has_val_) {
+ std::construct_at(std::addressof(__union_.__unex_), std::move(__un.error()));
+ __has_val_ = false;
+ } else {
+ __union_.__unex_ = std::move(__un.error());
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void emplace() noexcept {
+ if (!__has_val_) {
+ std::destroy_at(std::addressof(__union_.__unex_));
+ __has_val_ = true;
+ }
+ }
+
+ // [expected.void.swap], swap
+ _LIBCPP_HIDE_FROM_ABI constexpr void swap(expected& __rhs)
+ noexcept(is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>)
+ requires(is_swappable_v<_Err> && is_move_constructible_v<_Err>)
+ {
+ auto __swap_val_unex_impl = [&](expected& __with_val, expected& __with_err) {
+ std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__with_err.__union_.__unex_));
+ std::destroy_at(std::addressof(__with_err.__union_.__unex_));
+ __with_val.__has_val_ = false;
+ __with_err.__has_val_ = true;
+ };
+
+ if (__has_val_) {
+ if (!__rhs.__has_val_) {
+ __swap_val_unex_impl(*this, __rhs);
+ }
+ } else {
+ if (__rhs.__has_val_) {
+ __swap_val_unex_impl(__rhs, *this);
+ } else {
+ using std::swap;
+ swap(__union_.__unex_, __rhs.__union_.__unex_);
+ }
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(expected& __x, expected& __y)
+ noexcept(noexcept(__x.swap(__y)))
+ requires requires { __x.swap(__y); }
+ {
+ __x.swap(__y);
+ }
+
+ // [expected.void.obs], observers
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __has_val_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __has_val_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void operator*() const noexcept {
+ _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void value() const& {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void value() && {
+ if (!__has_val_) {
+ __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return __union_.__unex_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return __union_.__unex_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return std::move(__union_.__unex_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept {
+ _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
+ return std::move(__union_.__unex_);
+ }
+
+ // [expected.void.eq], equality operators
+ template <class _T2, class _E2>
+ requires is_void_v<_T2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
+ if (__x.__has_val_ != __y.__has_val_) {
+ return false;
+ } else {
+ return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ == __y.__union_.__unex_);
+ }
+ }
+
+ template <class _E2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) {
+ return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __y.error());
+ }
+
+private:
+ struct __empty_t {};
+ // use named union because [[no_unique_address]] cannot be applied to an unnamed union
+ _LIBCPP_NO_UNIQUE_ADDRESS union __union_t {
+ _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
+ requires(is_trivially_destructible_v<_Err>)
+ = default;
+
+ // the expected's destructor handles this
+ _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
+ requires(!is_trivially_destructible_v<_Err>)
+ {}
+
+ _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Err __unex_;
+ } __union_;
+
+ bool __has_val_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___EXPECTED_EXPECTED_H
diff --git a/libcxx/include/__expected/unexpect.h b/libcxx/include/__expected/unexpect.h
new file mode 100644
index 000000000000..20bafc1107c0
--- /dev/null
+++ b/libcxx/include/__expected/unexpect.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___EXPECTED_UNEXPECT_H
+#define _LIBCPP___EXPECTED_UNEXPECT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct unexpect_t {
+ _LIBCPP_HIDE_FROM_ABI explicit unexpect_t() = default;
+};
+
+inline constexpr unexpect_t unexpect{};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___EXPECTED_UNEXPECT_H
diff --git a/libcxx/include/__expected/unexpected.h b/libcxx/include/__expected/unexpected.h
new file mode 100644
index 000000000000..075963a84ded
--- /dev/null
+++ b/libcxx/include/__expected/unexpected.h
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___EXPECTED_UNEXPECTED_H
+#define _LIBCPP___EXPECTED_UNEXPECTED_H
+
+#include <__config>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/is_volatile.h>
+#include <__type_traits/negation.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Err>
+class unexpected;
+
+template <class _Tp>
+struct __is_std_unexpected : false_type {};
+
+template <class _Err>
+struct __is_std_unexpected<unexpected<_Err>> : true_type {};
+
+template <class _Tp>
+using __valid_std_unexpected = _BoolConstant< //
+ is_object_v<_Tp> && //
+ !is_array_v<_Tp> && //
+ !__is_std_unexpected<_Tp>::value && //
+ !is_const_v<_Tp> && //
+ !is_volatile_v<_Tp> //
+ >;
+
+template <class _Err>
+class unexpected {
+ static_assert(__valid_std_unexpected<_Err>::value,
+ "[expected.un.general] states a program that instantiates std::unexpected for a non-object type, an "
+ "array type, a specialization of unexpected, or a cv-qualified type is ill-formed.");
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr unexpected(const unexpected&) = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr unexpected(unexpected&&) = default;
+
+ template <class _Error = _Err>
+ requires(!is_same_v<remove_cvref_t<_Error>, unexpected> && //
+ !is_same_v<remove_cvref_t<_Error>, in_place_t> && //
+ is_constructible_v<_Err, _Error>)
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(_Error&& __error) //
+ noexcept(is_nothrow_constructible_v<_Err, _Error>) // strengthened
+ : __unex_(std::forward<_Error>(__error)) {}
+
+ template <class... _Args>
+ requires is_constructible_v<_Err, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(in_place_t, _Args&&... __args) //
+ noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
+ : __unex_(std::forward<_Args>(__args)...) {}
+
+ template <class _Up, class... _Args>
+ requires is_constructible_v<_Err, initializer_list<_Up>&, _Args...>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) //
+ noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
+ : __unex_(__il, std::forward<_Args>(__args)...) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(const unexpected&) = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(unexpected&&) = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { return __unex_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { return __unex_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { return std::move(__unex_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { return std::move(__unex_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Err>) {
+ static_assert(is_swappable_v<_Err>, "unexpected::swap requires is_swappable_v<E> to be true");
+ using std::swap;
+ swap(__unex_, __other.__unex_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(unexpected& __x, unexpected& __y) noexcept(noexcept(__x.swap(__y)))
+ requires is_swappable_v<_Err>
+ {
+ __x.swap(__y);
+ }
+
+ template <class _Err2>
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err2>& __y) {
+ return __x.__unex_ == __y.__unex_;
+ }
+
+private:
+ _Err __unex_;
+};
+
+template <class _Err>
+unexpected(_Err) -> unexpected<_Err>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___EXPECTED_UNEXPECTED_H
diff --git a/libcxx/include/__filesystem/directory_entry.h b/libcxx/include/__filesystem/directory_entry.h
index 5ba3ef96de48..b17eaaab4c54 100644
--- a/libcxx/include/__filesystem/directory_entry.h
+++ b/libcxx/include/__filesystem/directory_entry.h
@@ -215,22 +215,24 @@ public:
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_;
}
+#if _LIBCPP_STD_VER <= 17
_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_;
}
@@ -245,6 +247,15 @@ public:
return __p_ >= __rhs.__p_;
}
+#else // _LIBCPP_STD_VER <= 17
+
+ _LIBCPP_HIDE_FROM_ABI
+ strong_ordering operator<=>(const directory_entry& __rhs) const noexcept {
+ return __p_ <=> __rhs.__p_;
+ }
+
+#endif // _LIBCPP_STD_VER <= 17
+
template <class _CharT, class _Traits>
_LIBCPP_INLINE_VISIBILITY
friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) {
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index e32b14c1b7bf..effe6998338c 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -14,6 +14,7 @@
#include <__config>
#include <__filesystem/path.h>
#include <__memory/shared_ptr.h>
+#include <__utility/forward.h>
#include <iosfwd>
#include <new>
#include <system_error>
@@ -60,7 +61,7 @@ public:
filesystem_error(const filesystem_error&) = default;
~filesystem_error() override; // key function
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
const char* what() const noexcept override {
return __storage_->__what_.c_str();
}
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index 8fafd72c7e4f..4e6912fcf3e7 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -141,15 +141,15 @@ struct __is_pathable_string<
template <class _Source, class _DS = typename decay<_Source>::type,
class _UnqualPtrType =
- typename remove_const<typename remove_pointer<_DS>::type>::type,
+ __remove_const_t<__remove_pointer_t<_DS> >,
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>;
+ : __can_convert_char<__remove_const_t<_ECharT> > {
+ using _Base = __can_convert_char<__remove_const_t<_ECharT> >;
_LIBCPP_HIDE_FROM_ABI
static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
@@ -619,7 +619,7 @@ public:
_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));
+ bool __source_is_absolute = _VSTD_FS::__is_separator(_Traits::__first_or_null(__src));
if (__source_is_absolute)
__pn_.clear();
else if (has_filename())
@@ -634,7 +634,7 @@ public:
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
using _CVT = _PathCVT<_ItVal>;
- if (__first != __last && __is_separator(*__first))
+ if (__first != __last && _VSTD_FS::__is_separator(*__first))
__pn_.clear();
else if (has_filename())
__pn_ += preferred_separator;
@@ -732,6 +732,37 @@ public:
path& replace_extension(const path& __replacement = path());
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) == 0;
+ }
+# if _LIBCPP_STD_VER <= 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) != 0;
+ }
+ friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) < 0;
+ }
+ friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) <= 0;
+ }
+ friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) > 0;
+ }
+ friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) >= 0;
+ }
+# else // _LIBCPP_STD_VER <= 17
+ friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.__compare(__rhs.__pn_) <=> 0;
+ }
+# endif // _LIBCPP_STD_VER <= 17
+
+ friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
+ path __result(__lhs);
+ __result /= __rhs;
+ return __result;
+ }
+
_LIBCPP_HIDE_FROM_ABI
void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
@@ -835,7 +866,7 @@ public:
using _Str = basic_string<_ECharT, _Traits, _Allocator>;
_Str __s(__a);
__s.reserve(__pn_.size());
- _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
+ _CVT()(std::back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
return __s;
}
@@ -1035,30 +1066,6 @@ public:
}
#endif // !_LIBCPP_HAS_NO_LOCALIZATION
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) == 0;
- }
- friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) != 0;
- }
- friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) < 0;
- }
- friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) <= 0;
- }
- friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) > 0;
- }
- friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.__compare(__rhs.__pn_) >= 0;
- }
-
- friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
- path __result(__lhs);
- __result /= __rhs;
- return __result;
- }
private:
inline _LIBCPP_HIDE_FROM_ABI path&
__assign_view(__string_view const& __s) noexcept {
diff --git a/libcxx/include/__filesystem/space_info.h b/libcxx/include/__filesystem/space_info.h
index d7dc03af75a7..d0747e35ebf0 100644
--- a/libcxx/include/__filesystem/space_info.h
+++ b/libcxx/include/__filesystem/space_info.h
@@ -28,6 +28,10 @@ struct _LIBCPP_TYPE_VIS space_info {
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
+
+# if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const space_info&, const space_info&) = default;
+# endif
};
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index d9b08064dfb3..ddfe76728e9b 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -11,22 +11,27 @@
#define _LIBCPP___FORMAT_BUFFER_H
#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
#include <__algorithm/max.h>
#include <__algorithm/min.h>
+#include <__algorithm/ranges_copy_n.h>
+#include <__algorithm/transform.h>
#include <__algorithm/unwrap_iter.h>
+#include <__concepts/same_as.h>
#include <__config>
+#include <__format/concepts.h>
#include <__format/enable_insertable.h>
#include <__format/format_to_n_result.h>
-#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/wrap_iter.h>
#include <__utility/move.h>
-#include <concepts>
#include <cstddef>
+#include <string_view>
#include <type_traits>
+#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -46,41 +51,125 @@ namespace __format {
/// This helper is used together with the @ref back_insert_iterator to offer
/// type-erasure for the formatting functions. This reduces the number to
/// template instantiations.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __output_buffer {
public:
using value_type = _CharT;
template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr,
- size_t __capacity, _Tp* __obj)
- : __ptr_(__ptr), __capacity_(__capacity),
- __flush_([](_CharT* __p, size_t __size, void* __o) {
- static_cast<_Tp*>(__o)->flush(__p, __size);
- }),
+ _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj)
+ : __ptr_(__ptr),
+ __capacity_(__capacity),
+ __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }),
__obj_(__obj) {}
- _LIBCPP_HIDE_FROM_ABI void reset(_CharT* __ptr, size_t __capacity) {
+ _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) {
__ptr_ = __ptr;
__capacity_ = __capacity;
}
- _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
- return back_insert_iterator{*this};
- }
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return std::back_insert_iterator{*this}; }
- // TODO FMT It would be nice to have an overload taking a
- // basic_string_view<_CharT> and append it directly.
+ // Used in std::back_insert_iterator.
_LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
__ptr_[__size_++] = __c;
// Profiling showed flushing after adding is more efficient than flushing
// when entering the function.
if (__size_ == __capacity_)
- flush();
+ __flush();
+ }
+
+ /// Copies the input __str to the buffer.
+ ///
+ /// Since some of the input is generated by std::to_chars, there needs to be a
+ /// conversion when _CharT is wchar_t.
+ template <__fmt_char_type _InCharT>
+ _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) {
+ // When the underlying iterator is a simple iterator the __capacity_ is
+ // infinite. For a string or container back_inserter it isn't. This means
+ // adding a large string the the buffer can cause some overhead. In that
+ // case a better approach could be:
+ // - flush the buffer
+ // - container.append(__str.begin(), __str.end());
+ // The same holds true for the fill.
+ // For transform it might be slightly harder, however the use case for
+ // transform is slightly less common; it converts hexadecimal values to
+ // upper case. For integral these strings are short.
+ // TODO FMT Look at the improvements above.
+ size_t __n = __str.size();
+
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::copy_n(__str.data(), __n, _VSTD::addressof(__ptr_[__size_]));
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Copy the data in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ const _InCharT* __first = __str.data();
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::copy_n(__first, __chunk, _VSTD::addressof(__ptr_[__size_]));
+ __size_ = __chunk;
+ __first += __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
+ }
+
+ /// A std::transform wrapper.
+ ///
+ /// Like @ref __copy it may need to do type conversion.
+ template <__fmt_char_type _InCharT, class _UnaryOperation>
+ _LIBCPP_HIDE_FROM_ABI void __transform(const _InCharT* __first, const _InCharT* __last, _UnaryOperation __operation) {
+ _LIBCPP_ASSERT(__first <= __last, "not a valid range");
+
+ size_t __n = static_cast<size_t>(__last - __first);
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::transform(__first, __last, _VSTD::addressof(__ptr_[__size_]), _VSTD::move(__operation));
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Transform the data in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::transform(__first, __first + __chunk, _VSTD::addressof(__ptr_[__size_]), __operation);
+ __size_ = __chunk;
+ __first += __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
+ }
+
+ /// A \c fill_n wrapper.
+ _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) {
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __n, __value);
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Fill the buffer in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __chunk, __value);
+ __size_ = __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
}
- _LIBCPP_HIDE_FROM_ABI void flush() {
+ _LIBCPP_HIDE_FROM_ABI void __flush() {
__flush_(__ptr_, __size_, __obj_);
__size_ = 0;
}
@@ -91,16 +180,54 @@ private:
size_t __size_{0};
void (*__flush_)(_CharT*, size_t, void*);
void* __obj_;
+
+ /// Flushes the buffer when the output operation would overflow the buffer.
+ ///
+ /// A simple approach for the overflow detection would be something along the
+ /// lines:
+ /// \code
+ /// // The internal buffer is large enough.
+ /// if (__n <= __capacity_) {
+ /// // Flush when we really would overflow.
+ /// if (__size_ + __n >= __capacity_)
+ /// __flush();
+ /// ...
+ /// }
+ /// \endcode
+ ///
+ /// This approach works for all cases but one:
+ /// A __format_to_n_buffer_base where \ref __enable_direct_output is true.
+ /// In that case the \ref __capacity_ of the buffer changes during the first
+ /// \ref __flush. During that operation the output buffer switches from its
+ /// __writer_ to its __storage_. The \ref __capacity_ of the former depends
+ /// on the value of n, of the latter is a fixed size. For example:
+ /// - a format_to_n call with a 10'000 char buffer,
+ /// - the buffer is filled with 9'500 chars,
+ /// - adding 1'000 elements would overflow the buffer so the buffer gets
+ /// changed and the \ref __capacity_ decreases from 10'000 to
+ /// __buffer_size (256 at the time of writing).
+ ///
+ /// This means that the \ref __flush for this class may need to copy a part of
+ /// the internal buffer to the proper output. In this example there will be
+ /// 500 characters that need this copy operation.
+ ///
+ /// Note it would be more efficient to write 500 chars directly and then swap
+ /// the buffers. This would make the code more complex and \ref format_to_n is
+ /// not the most common use case. Therefore the optimization isn't done.
+ _LIBCPP_HIDE_FROM_ABI void __flush_on_overflow(size_t __n) {
+ if (__size_ + __n >= __capacity_)
+ __flush();
+ }
};
/// A storage using an internal buffer.
///
/// This storage is used when writing a single element to the output iterator
/// is expensive.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __internal_storage {
public:
- _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }
+ _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; }
static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
@@ -113,11 +240,11 @@ private:
/// This requires the storage to be a contiguous buffer of \a _CharT.
/// Since the output is directly written to the underlying storage this class
/// is just an empty class.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __direct_storage {};
template <class _OutIt, class _CharT>
-concept __enable_direct_output = __formatter::__char_type<_CharT> &&
+concept __enable_direct_output = __fmt_char_type<_CharT> &&
(same_as<_OutIt, _CharT*>
#ifndef _LIBCPP_ENABLE_DEBUG_MODE
|| same_as<_OutIt, __wrap_iter<_CharT*>>
@@ -125,18 +252,18 @@ concept __enable_direct_output = __formatter::__char_type<_CharT> &&
);
/// Write policy for directly writing to the underlying output.
-template <class _OutIt, __formatter::__char_type _CharT>
+template <class _OutIt, __fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __writer_direct {
public:
_LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
: __out_it_(__out_it) {}
- _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() { return __out_it_; }
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT*, size_t __size) {
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT*, size_t __n) {
// _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
// is adjusted.
- __out_it_ += __size;
+ __out_it_ += __n;
}
private:
@@ -144,16 +271,16 @@ private:
};
/// Write policy for copying the buffer to the output.
-template <class _OutIt, __formatter::__char_type _CharT>
+template <class _OutIt, __fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __writer_iterator {
public:
_LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
: __out_it_{_VSTD::move(__out_it)} {}
- _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return std::move(__out_it_); }
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
- __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_));
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out;
}
private:
@@ -169,7 +296,7 @@ private:
/// \ref __enable_insertable.
template <class _Container>
concept __insertable =
- __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> &&
+ __enable_insertable<_Container> && __fmt_char_type<typename _Container::value_type> &&
requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
@@ -193,10 +320,10 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
: __container_{__out_it.__get_container()} {}
- _LIBCPP_HIDE_FROM_ABI auto out() { return back_inserter(*__container_); }
+ _LIBCPP_HIDE_FROM_ABI auto __out_it() { return std::back_inserter(*__container_); }
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
- __container_->insert(__container_->end(), __ptr, __ptr + __size);
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ __container_->insert(__container_->end(), __ptr, __ptr + __n);
}
private:
@@ -215,7 +342,7 @@ public:
};
/// The generic formatting buffer.
-template <class _OutIt, __formatter::__char_type _CharT>
+template <class _OutIt, __fmt_char_type _CharT>
requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
__format_buffer {
using _Storage =
@@ -225,24 +352,20 @@ requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
public:
_LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
requires(same_as<_Storage, __internal_storage<_CharT>>)
- : __output_(__storage_.begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
+ : __output_(__storage_.__begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
_LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
same_as<_Storage, __direct_storage<_CharT>>)
: __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
__writer_(_VSTD::move(__out_it)) {}
- _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
- return __output_.make_output_iterator();
- }
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
- __writer_.flush(__ptr, __size);
- }
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); }
- _LIBCPP_HIDE_FROM_ABI _OutIt out() && {
- __output_.flush();
- return _VSTD::move(__writer_).out();
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && {
+ __output_.__flush();
+ return _VSTD::move(__writer_).__out_it();
}
private:
@@ -255,46 +378,46 @@ private:
///
/// Since \ref formatted_size only needs to know the size, the output itself is
/// discarded.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
public:
- _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return __output_.make_output_iterator(); }
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
- _LIBCPP_HIDE_FROM_ABI void flush(const _CharT*, size_t __size) { __size_ += __size; }
+ _LIBCPP_HIDE_FROM_ABI void __flush(const _CharT*, size_t __n) { __size_ += __n; }
- _LIBCPP_HIDE_FROM_ABI size_t result() && {
- __output_.flush();
+ _LIBCPP_HIDE_FROM_ABI size_t __result() && {
+ __output_.__flush();
return __size_;
}
private:
__internal_storage<_CharT> __storage_;
- __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
+ __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
size_t __size_{0};
};
/// The base of a buffer that counts and limits the number of insertions.
-template <class _OutIt, __formatter::__char_type _CharT, bool>
+template <class _OutIt, __fmt_char_type _CharT, bool>
requires(output_iterator<_OutIt, const _CharT&>)
struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
using _Size = iter_difference_t<_OutIt>;
public:
- _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
- : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {}
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
+ : __writer_(_VSTD::move(__out_it)), __max_size_(_VSTD::max(_Size(0), __max_size)) {}
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
- if (_Size(__size_) <= __n_)
- __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_));
- __size_ += __size;
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ if (_Size(__size_) <= __max_size_)
+ __writer_.__flush(__ptr, _VSTD::min(_Size(__n), __max_size_ - __size_));
+ __size_ += __n;
}
protected:
__internal_storage<_CharT> __storage_;
- __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
+ __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
typename __writer_selector<_OutIt, _CharT>::type __writer_;
- _Size __n_;
+ _Size __max_size_;
_Size __size_{0};
};
@@ -302,35 +425,46 @@ protected:
///
/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
///
-/// This class limits the size available the the direct writer so it will not
+/// This class limits the size available to the direct writer so it will not
/// exceed the maximum number of code units.
-template <class _OutIt, __formatter::__char_type _CharT>
+template <class _OutIt, __fmt_char_type _CharT>
requires(output_iterator<_OutIt, const _CharT&>)
class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
using _Size = iter_difference_t<_OutIt>;
public:
- _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
- : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {
- if (__n <= 0) [[unlikely]]
- __output_.reset(__storage_.begin(), __storage_.__buffer_size);
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
+ : __output_(_VSTD::__unwrap_iter(__out_it), __max_size, this),
+ __writer_(_VSTD::move(__out_it)),
+ __max_size_(__max_size) {
+ if (__max_size <= 0) [[unlikely]]
+ __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
}
- _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
- // A flush to the direct writer happens in two occasions:
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ // A __flush to the direct writer happens in the following occasions:
// - The format function has written the maximum number of allowed code
// units. At this point it's no longer valid to write to this writer. So
// switch to the internal storage. This internal storage doesn't need to
- // be written anywhere so the flush for that storage writes no output.
+ // be written anywhere so the __flush for that storage writes no output.
+ // - Like above, but the next "mass write" operation would overflow the
+ // buffer. In that case the buffer is pre-emptively switched. The still
+ // valid code units will be written separately.
// - The format_to_n function is finished. In this case there's no need to
// switch the buffer, but for simplicity the buffers are still switched.
- // When the __n <= 0 the constructor already switched the buffers.
- if (__size_ == 0 && __ptr != __storage_.begin()) {
- __writer_.flush(__ptr, __size);
- __output_.reset(__storage_.begin(), __storage_.__buffer_size);
+ // When the __max_size <= 0 the constructor already switched the buffers.
+ if (__size_ == 0 && __ptr != __storage_.__begin()) {
+ __writer_.__flush(__ptr, __n);
+ __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
+ } else if (__size_ < __max_size_) {
+ // Copies a part of the internal buffer to the output up to n characters.
+ // See __output_buffer<_CharT>::__flush_on_overflow for more information.
+ _Size __s = _VSTD::min(_Size(__n), __max_size_ - __size_);
+ std::copy_n(__ptr, __s, __writer_.__out_it());
+ __writer_.__flush(__ptr, __s);
}
- __size_ += __size;
+ __size_ += __n;
}
protected:
@@ -338,11 +472,12 @@ protected:
__output_buffer<_CharT> __output_;
__writer_direct<_OutIt, _CharT> __writer_;
+ _Size __max_size_;
_Size __size_{0};
};
/// The buffer that counts and limits the number of insertions.
-template <class _OutIt, __formatter::__char_type _CharT>
+template <class _OutIt, __fmt_char_type _CharT>
requires(output_iterator<_OutIt, const _CharT&>)
struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
: public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {
@@ -350,14 +485,83 @@ struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
using _Size = iter_difference_t<_OutIt>;
public:
- _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {}
- _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); }
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size)
+ : _Base(_VSTD::move(__out_it), __max_size) {}
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return this->__output_.__make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && {
+ this->__output_.__flush();
+ return {_VSTD::move(this->__writer_).__out_it(), this->__size_};
+ }
+};
+
+// A dynamically growing buffer intended to be used for retargeting a context.
+//
+// P2286 Formatting ranges adds range formatting support. It allows the user to
+// specify the minimum width for the entire formatted range. The width of the
+// range is not known until the range is formatted. Formatting is done to an
+// output_iterator so there's no guarantee it would be possible to add the fill
+// to the front of the output. Instead the range is formatted to a temporary
+// buffer and that buffer is formatted as a string.
+//
+// There is an issue with that approach, the format context used in
+// std::formatter<T>::format contains the output iterator used as part of its
+// type. So using this output iterator means there needs to be a new format
+// context and the format arguments need to be retargeted to the new context.
+// This retargeting is done by a basic_format_context specialized for the
+// __iterator of this container.
+template <__fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __retarget_buffer {
+public:
+ using value_type = _CharT;
+
+ struct __iterator {
+ using difference_type = ptrdiff_t;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(__retarget_buffer& __buffer)
+ : __buffer_(std::addressof(__buffer)) {}
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator=(const _CharT& __c) {
+ __buffer_->push_back(__c);
+ return *this;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator=(_CharT&& __c) {
+ __buffer_->push_back(__c);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator*() { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) { return *this; }
+ __retarget_buffer* __buffer_;
+ };
- _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && {
- this->__output_.flush();
- return {_VSTD::move(this->__writer_).out(), this->__size_};
+ _LIBCPP_HIDE_FROM_ABI explicit __retarget_buffer(size_t __size_hint) { __buffer_.reserve(__size_hint); }
+
+ _LIBCPP_HIDE_FROM_ABI __iterator __make_output_iterator() { return __iterator{*this}; }
+
+ _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) { __buffer_.push_back(__c); }
+
+ template <__fmt_char_type _InCharT>
+ _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) {
+ __buffer_.insert(__buffer_.end(), __str.begin(), __str.end());
+ }
+
+ template <__fmt_char_type _InCharT, class _UnaryOperation>
+ _LIBCPP_HIDE_FROM_ABI void __transform(const _InCharT* __first, const _InCharT* __last, _UnaryOperation __operation) {
+ _LIBCPP_ASSERT(__first <= __last, "not a valid range");
+ std::transform(__first, __last, std::back_inserter(__buffer_), std::move(__operation));
}
+
+ _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) { __buffer_.insert(__buffer_.end(), __n, __value); }
+
+ _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT> __view() { return {__buffer_.data(), __buffer_.size()}; }
+
+private:
+ // Use vector instead of string to avoid adding zeros after every append
+ // operation. The buffer is exposed as a string_view and not as a c-string.
+ vector<_CharT> __buffer_;
};
+
} // namespace __format
#endif //_LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__format/concepts.h b/libcxx/include/__format/concepts.h
index 8df6493b0aed..fe4a7b9625ce 100644
--- a/libcxx/include/__format/concepts.h
+++ b/libcxx/include/__format/concepts.h
@@ -15,6 +15,9 @@
#include <__config>
#include <__format/format_fwd.h>
#include <__format/format_parse_context.h>
+#include <__type_traits/is_specialization.h>
+#include <__utility/pair.h>
+#include <tuple>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -25,6 +28,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
+/// The character type specializations of \ref formatter.
+template <class _CharT>
+concept __fmt_char_type =
+ same_as<_CharT, char>
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ || same_as<_CharT, wchar_t>
+# endif
+ ;
+
// The output iterator isn't specified. A formatter should accept any
// output_iterator. This iterator is a minimal iterator to test the concept.
// (Note testing for (w)format_context would be a valid choice, but requires
@@ -32,20 +44,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT>
using __fmt_iter_for = _CharT*;
-// The concept is based on P2286R6
-// It lacks the const of __cf as required by, the not yet accepted, LWG-3636.
-// The current formatters can't be easily adapted, but that is WIP.
-// TODO FMT properly implement this concepts once accepted.
template <class _Tp, class _CharT>
-concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
- requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
- formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t,
- basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
- basic_format_parse_context<_CharT> __pc) {
- { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
- { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
- };
+concept __formattable =
+ (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
+ requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
+ const formatter<remove_cvref_t<_Tp>, _CharT> __cf,
+ _Tp __t,
+ basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
+ basic_format_parse_context<_CharT> __pc) {
+ { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
+ { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
+ };
+
+# if _LIBCPP_STD_VER > 20
+template <class _Tp, class _CharT>
+concept formattable = __formattable<_Tp, _CharT>;
+
+// [tuple.like] defines a tuple-like exposition only concept. This concept is
+// not related to that. Therefore it uses a different name for the concept.
+//
+// TODO FMT Add a test to validate we fail when using that concept after P2165
+// has been implemented.
+template <class _Tp>
+concept __fmt_pair_like = __is_specialization_v<_Tp, pair> ||
+ // Use a requires since tuple_size_v may fail to instantiate,
+ (__is_specialization_v<_Tp, tuple> && requires { tuple_size_v<_Tp> == 2; });
+# endif //_LIBCPP_STD_VER > 20
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__format/container_adaptor.h b/libcxx/include/__format/container_adaptor.h
new file mode 100644
index 000000000000..62b698186ea1
--- /dev/null
+++ b/libcxx/include/__format/container_adaptor.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___FORMAT_CONTAINER_ADAPTOR_H
+#define _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__availability>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/formatter.h>
+#include <__format/range_default_formatter.h>
+#include <queue>
+#include <stack>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+// [container.adaptors.format] only specifies the library should provide the
+// formatter specializations, not which header should provide them.
+// Since <format> includes a lot of headers, add these headers here instead of
+// adding more dependencies like, locale, optinal, string, tuple, etc. to the
+// adaptor headers. To use the format functions users already include <format>.
+
+template <class _Adaptor, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_container_adaptor {
+private:
+ using __maybe_const_adaptor = __fmt_maybe_const<_Adaptor, _CharT>;
+ formatter<typename _Adaptor::container_type, _CharT> __underlying_;
+
+public:
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
+ format(__maybe_const_adaptor& __adaptor, _FormatContext& __ctx) const {
+ return __underlying_.format(__adaptor.__get_container(), __ctx);
+ }
+};
+
+template <class _CharT, class _Tp, formattable<_CharT> _Container>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<queue<_Tp, _Container>, _CharT>
+ : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {};
+
+template <class _CharT, class _Tp, class _Container, class _Compare>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<priority_queue<_Tp, _Container, _Compare>, _CharT>
+ : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {};
+
+template <class _CharT, class _Tp, formattable<_CharT> _Container>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<stack<_Tp, _Container>, _CharT>
+ : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
diff --git a/libcxx/include/__format/escaped_output_table.h b/libcxx/include/__format/escaped_output_table.h
new file mode 100644
index 000000000000..bd2994bdc66d
--- /dev/null
+++ b/libcxx/include/__format/escaped_output_table.h
@@ -0,0 +1,1038 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// WARNING, this entire header is generated by
+// utils/generate_escaped_output_table.py
+// DO NOT MODIFY!
+
+// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+//
+// See Terms of Use <https://www.unicode.org/copyright.html>
+// for definitions of Unicode Inc.'s Data Files and Software.
+//
+// NOTICE TO USER: Carefully read the following legal agreement.
+// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
+// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
+// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
+// TERMS AND CONDITIONS OF THIS AGREEMENT.
+// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
+// THE DATA FILES OR SOFTWARE.
+//
+// COPYRIGHT AND PERMISSION NOTICE
+//
+// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
+// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of the Unicode data files and any associated documentation
+// (the "Data Files") or Unicode software and any associated documentation
+// (the "Software") to deal in the Data Files or Software
+// without restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, and/or sell copies of
+// the Data Files or Software, and to permit persons to whom the Data Files
+// or Software are furnished to do so, provided that either
+// (a) this copyright and permission notice appear with all copies
+// of the Data Files or Software, or
+// (b) this copyright and permission notice appear in associated
+// Documentation.
+//
+// THE DATA FILES AND SOFTWARE ARE 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 OF THIRD PARTY RIGHTS.
+// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+//
+// Except as contained in this notice, the name of a copyright holder
+// shall not be used in advertising or otherwise to promote the sale,
+// use or other dealings in these Data Files or Software without prior
+// written authorization of the copyright holder.
+
+#ifndef _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
+#define _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
+
+#include <__algorithm/ranges_upper_bound.h>
+#include <__config>
+#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 > 20
+
+namespace __escaped_output_table {
+
+/// The entries of the characters to escape in format's debug string.
+///
+/// Contains the entries for [format.string.escaped]/2.2.1.2.1
+/// CE is a Unicode encoding and C corresponds to either a UCS scalar value
+/// whose Unicode property General_Category has a value in the groups
+/// Separator (Z) or Other (C) or to a UCS scalar value which has the Unicode
+/// property Grapheme_Extend=Yes, as described by table 12 of UAX #44
+///
+/// Separator (Z) consists of General_Category
+/// - Space_Separator,
+/// - Line_Separator,
+/// - Paragraph_Separator.
+///
+/// Other (C) consists of General_Category
+/// - Control,
+/// - Format,
+/// - Surrogate,
+/// - Private_Use,
+/// - Unassigned.
+///
+/// The data is generated from
+/// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
+/// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt
+///
+/// The table is similar to the table
+/// __extended_grapheme_custer_property_boundary::__entries
+/// which explains the details of these classes. The only difference is this
+/// table lacks a property, thus having more bits available for the size.
+///
+/// The data has 2 values:
+/// - bits [0, 10] The size of the range, allowing 2048 elements.
+/// - bits [11, 31] The lower bound code point of the range. The upper bound of
+/// the range is lower bound + size.
+inline constexpr uint32_t __entries[893] = {
+ 0x00000020,
+ 0x0003f821,
+ 0x00056800,
+ 0x0018006f,
+ 0x001bc001,
+ 0x001c0003,
+ 0x001c5800,
+ 0x001c6800,
+ 0x001d1000,
+ 0x00241806,
+ 0x00298000,
+ 0x002ab801,
+ 0x002c5801,
+ 0x002c802d,
+ 0x002df800,
+ 0x002e0801,
+ 0x002e2001,
+ 0x002e3808,
+ 0x002f5803,
+ 0x002fa810,
+ 0x0030800a,
+ 0x0030e000,
+ 0x00325814,
+ 0x00338000,
+ 0x0036b007,
+ 0x0036f805,
+ 0x00373801,
+ 0x00375003,
+ 0x00387001,
+ 0x00388800,
+ 0x0039801c,
+ 0x003d300a,
+ 0x003d900d,
+ 0x003f5808,
+ 0x003fd802,
+ 0x0040b003,
+ 0x0040d808,
+ 0x00412802,
+ 0x00414806,
+ 0x0041f800,
+ 0x0042c804,
+ 0x0042f800,
+ 0x00435804,
+ 0x00447810,
+ 0x00465038,
+ 0x0049d000,
+ 0x0049e000,
+ 0x004a0807,
+ 0x004a6800,
+ 0x004a8806,
+ 0x004b1001,
+ 0x004c0800,
+ 0x004c2000,
+ 0x004c6801,
+ 0x004c8801,
+ 0x004d4800,
+ 0x004d8800,
+ 0x004d9802,
+ 0x004dd002,
+ 0x004df000,
+ 0x004e0805,
+ 0x004e4801,
+ 0x004e6800,
+ 0x004e780c,
+ 0x004ef000,
+ 0x004f1003,
+ 0x004ff004,
+ 0x00502000,
+ 0x00505803,
+ 0x00508801,
+ 0x00514800,
+ 0x00518800,
+ 0x0051a000,
+ 0x0051b800,
+ 0x0051d003,
+ 0x00520817,
+ 0x0052e800,
+ 0x0052f806,
+ 0x00538001,
+ 0x0053a800,
+ 0x0053b80b,
+ 0x00542000,
+ 0x00547000,
+ 0x00549000,
+ 0x00554800,
+ 0x00558800,
+ 0x0055a000,
+ 0x0055d002,
+ 0x00560807,
+ 0x00565000,
+ 0x00566802,
+ 0x0056880e,
+ 0x00571003,
+ 0x00579006,
+ 0x0057d007,
+ 0x00582000,
+ 0x00586801,
+ 0x00588801,
+ 0x00594800,
+ 0x00598800,
+ 0x0059a000,
+ 0x0059d002,
+ 0x0059f001,
+ 0x005a0805,
+ 0x005a4801,
+ 0x005a680e,
+ 0x005af000,
+ 0x005b1003,
+ 0x005bc00a,
+ 0x005c2000,
+ 0x005c5802,
+ 0x005c8800,
+ 0x005cb002,
+ 0x005cd800,
+ 0x005ce800,
+ 0x005d0002,
+ 0x005d2802,
+ 0x005d5802,
+ 0x005dd004,
+ 0x005e0000,
+ 0x005e1802,
+ 0x005e4800,
+ 0x005e6802,
+ 0x005e8814,
+ 0x005fd805,
+ 0x00602000,
+ 0x00606800,
+ 0x00608800,
+ 0x00614800,
+ 0x0061d002,
+ 0x0061f002,
+ 0x00622812,
+ 0x0062d801,
+ 0x0062f001,
+ 0x00631003,
+ 0x00638006,
+ 0x00640800,
+ 0x00646800,
+ 0x00648800,
+ 0x00654800,
+ 0x0065a000,
+ 0x0065d002,
+ 0x0065f800,
+ 0x00661000,
+ 0x00662801,
+ 0x00664800,
+ 0x00666010,
+ 0x0066f800,
+ 0x00671003,
+ 0x00678000,
+ 0x0067a00d,
+ 0x00686800,
+ 0x00688800,
+ 0x0069d801,
+ 0x0069f000,
+ 0x006a0804,
+ 0x006a4800,
+ 0x006a6800,
+ 0x006a8003,
+ 0x006ab800,
+ 0x006b1003,
+ 0x006c0001,
+ 0x006c2000,
+ 0x006cb802,
+ 0x006d9000,
+ 0x006de000,
+ 0x006df001,
+ 0x006e3808,
+ 0x006e9005,
+ 0x006ef806,
+ 0x006f8001,
+ 0x006fa80b,
+ 0x00718800,
+ 0x0071a00a,
+ 0x00723807,
+ 0x0072e024,
+ 0x00741800,
+ 0x00742800,
+ 0x00745800,
+ 0x00752000,
+ 0x00753000,
+ 0x00758800,
+ 0x0075a008,
+ 0x0075f001,
+ 0x00762800,
+ 0x00763808,
+ 0x0076d001,
+ 0x0077001f,
+ 0x0078c001,
+ 0x0079a800,
+ 0x0079b800,
+ 0x0079c800,
+ 0x007a4000,
+ 0x007b6811,
+ 0x007c0004,
+ 0x007c3001,
+ 0x007c6830,
+ 0x007e3000,
+ 0x007e6800,
+ 0x007ed824,
+ 0x00816803,
+ 0x00819005,
+ 0x0081c801,
+ 0x0081e801,
+ 0x0082c001,
+ 0x0082f002,
+ 0x00838803,
+ 0x00841000,
+ 0x00842801,
+ 0x00846800,
+ 0x0084e800,
+ 0x00863000,
+ 0x00864004,
+ 0x00867001,
+ 0x00924800,
+ 0x00927001,
+ 0x0092b800,
+ 0x0092c800,
+ 0x0092f001,
+ 0x00944800,
+ 0x00947001,
+ 0x00958800,
+ 0x0095b001,
+ 0x0095f800,
+ 0x00960800,
+ 0x00963001,
+ 0x0096b800,
+ 0x00988800,
+ 0x0098b001,
+ 0x009ad804,
+ 0x009be802,
+ 0x009cd005,
+ 0x009fb001,
+ 0x009ff001,
+ 0x00b40000,
+ 0x00b4e802,
+ 0x00b7c806,
+ 0x00b89002,
+ 0x00b8b008,
+ 0x00b99001,
+ 0x00b9b808,
+ 0x00ba900d,
+ 0x00bb6800,
+ 0x00bb880e,
+ 0x00bda001,
+ 0x00bdb806,
+ 0x00be3000,
+ 0x00be480a,
+ 0x00bee802,
+ 0x00bf5005,
+ 0x00bfd005,
+ 0x00c05804,
+ 0x00c0d005,
+ 0x00c3c806,
+ 0x00c42801,
+ 0x00c54800,
+ 0x00c55804,
+ 0x00c7b009,
+ 0x00c8f803,
+ 0x00c93801,
+ 0x00c96003,
+ 0x00c99000,
+ 0x00c9c806,
+ 0x00ca0802,
+ 0x00cb7001,
+ 0x00cba80a,
+ 0x00cd6003,
+ 0x00ce5005,
+ 0x00ced802,
+ 0x00d0b801,
+ 0x00d0d802,
+ 0x00d2b000,
+ 0x00d2c008,
+ 0x00d31000,
+ 0x00d32807,
+ 0x00d3980c,
+ 0x00d45005,
+ 0x00d4d005,
+ 0x00d57055,
+ 0x00d9a006,
+ 0x00d9e000,
+ 0x00da1000,
+ 0x00da6802,
+ 0x00db5808,
+ 0x00dbf802,
+ 0x00dd1003,
+ 0x00dd4001,
+ 0x00dd5802,
+ 0x00df3000,
+ 0x00df4001,
+ 0x00df6800,
+ 0x00df7802,
+ 0x00dfa007,
+ 0x00e16007,
+ 0x00e1b004,
+ 0x00e25002,
+ 0x00e44806,
+ 0x00e5d801,
+ 0x00e6400a,
+ 0x00e6a00c,
+ 0x00e71006,
+ 0x00e76800,
+ 0x00e7a000,
+ 0x00e7c001,
+ 0x00e7d804,
+ 0x00ee003f,
+ 0x00f8b001,
+ 0x00f8f001,
+ 0x00fa3001,
+ 0x00fa7001,
+ 0x00fac000,
+ 0x00fad000,
+ 0x00fae000,
+ 0x00faf000,
+ 0x00fbf001,
+ 0x00fda800,
+ 0x00fe2800,
+ 0x00fea001,
+ 0x00fee000,
+ 0x00ff8001,
+ 0x00ffa800,
+ 0x00fff810,
+ 0x01014007,
+ 0x0102f810,
+ 0x01039001,
+ 0x01047800,
+ 0x0104e802,
+ 0x0106083e,
+ 0x010c6003,
+ 0x01213818,
+ 0x01225814,
+ 0x015ba001,
+ 0x015cb000,
+ 0x01677802,
+ 0x0167a004,
+ 0x01693000,
+ 0x01694004,
+ 0x01697001,
+ 0x016b4006,
+ 0x016b880e,
+ 0x016cb808,
+ 0x016d3800,
+ 0x016d7800,
+ 0x016db800,
+ 0x016df800,
+ 0x016e3800,
+ 0x016e7800,
+ 0x016eb800,
+ 0x016ef820,
+ 0x0172f021,
+ 0x0174d000,
+ 0x0177a00b,
+ 0x017eb019,
+ 0x017fe004,
+ 0x01815005,
+ 0x01820000,
+ 0x0184b803,
+ 0x01880004,
+ 0x01898000,
+ 0x018c7800,
+ 0x018f200b,
+ 0x0190f800,
+ 0x05246802,
+ 0x05263808,
+ 0x05316013,
+ 0x05337803,
+ 0x0533a009,
+ 0x0534f001,
+ 0x05378001,
+ 0x0537c007,
+ 0x053e5804,
+ 0x053e9000,
+ 0x053ea000,
+ 0x053ed017,
+ 0x05401000,
+ 0x05403000,
+ 0x05405800,
+ 0x05412801,
+ 0x05416003,
+ 0x0541d005,
+ 0x0543c007,
+ 0x05462009,
+ 0x0546d017,
+ 0x0547f800,
+ 0x05493007,
+ 0x054a380a,
+ 0x054aa00a,
+ 0x054be805,
+ 0x054d9800,
+ 0x054db003,
+ 0x054de001,
+ 0x054e7000,
+ 0x054ed003,
+ 0x054f2800,
+ 0x054ff800,
+ 0x05514805,
+ 0x05518801,
+ 0x0551a80a,
+ 0x05521800,
+ 0x05526000,
+ 0x05527001,
+ 0x0552d001,
+ 0x0553e000,
+ 0x05558000,
+ 0x05559002,
+ 0x0555b801,
+ 0x0555f001,
+ 0x05560800,
+ 0x05561817,
+ 0x05576001,
+ 0x0557b00a,
+ 0x05583801,
+ 0x05587801,
+ 0x0558b808,
+ 0x05593800,
+ 0x05597800,
+ 0x055b6003,
+ 0x055f2800,
+ 0x055f4000,
+ 0x055f6802,
+ 0x055fd005,
+ 0x06bd200b,
+ 0x06be3803,
+ 0x06bfe7ff,
+ 0x06ffe7ff,
+ 0x073fe7ff,
+ 0x077fe7ff,
+ 0x07bfe103,
+ 0x07d37001,
+ 0x07d6d025,
+ 0x07d8380b,
+ 0x07d8c004,
+ 0x07d8f000,
+ 0x07d9b800,
+ 0x07d9e800,
+ 0x07d9f800,
+ 0x07da1000,
+ 0x07da2800,
+ 0x07de180f,
+ 0x07ec8001,
+ 0x07ee4006,
+ 0x07ee801f,
+ 0x07f0000f,
+ 0x07f0d015,
+ 0x07f29800,
+ 0x07f33800,
+ 0x07f36003,
+ 0x07f3a800,
+ 0x07f7e803,
+ 0x07fcf001,
+ 0x07fdf802,
+ 0x07fe4001,
+ 0x07fe8001,
+ 0x07fec001,
+ 0x07fee802,
+ 0x07ff3800,
+ 0x07ff780c,
+ 0x07fff001,
+ 0x08006000,
+ 0x08013800,
+ 0x0801d800,
+ 0x0801f000,
+ 0x08027001,
+ 0x0802f021,
+ 0x0807d804,
+ 0x08081803,
+ 0x0809a002,
+ 0x080c7800,
+ 0x080ce802,
+ 0x080d082e,
+ 0x080fe882,
+ 0x0814e802,
+ 0x0816880f,
+ 0x0817e003,
+ 0x08192008,
+ 0x081a5804,
+ 0x081bb009,
+ 0x081cf000,
+ 0x081e2003,
+ 0x081eb029,
+ 0x0824f001,
+ 0x08255005,
+ 0x0826a003,
+ 0x0827e003,
+ 0x08294007,
+ 0x082b200a,
+ 0x082bd800,
+ 0x082c5800,
+ 0x082c9800,
+ 0x082cb000,
+ 0x082d1000,
+ 0x082d9000,
+ 0x082dd000,
+ 0x082de842,
+ 0x0839b808,
+ 0x083ab009,
+ 0x083b4017,
+ 0x083c3000,
+ 0x083d8800,
+ 0x083dd844,
+ 0x08403001,
+ 0x08404800,
+ 0x0841b000,
+ 0x0841c802,
+ 0x0841e801,
+ 0x0842b000,
+ 0x0844f807,
+ 0x0845802f,
+ 0x08479800,
+ 0x0847b004,
+ 0x0848e002,
+ 0x0849d004,
+ 0x084a003f,
+ 0x084dc003,
+ 0x084e8001,
+ 0x0850080e,
+ 0x0850a000,
+ 0x0850c000,
+ 0x0851b009,
+ 0x08524806,
+ 0x0852c806,
+ 0x0855001f,
+ 0x08572805,
+ 0x0857b808,
+ 0x0859b002,
+ 0x085ab001,
+ 0x085b9804,
+ 0x085c9006,
+ 0x085ce80b,
+ 0x085d804f,
+ 0x08624836,
+ 0x0865980c,
+ 0x08679806,
+ 0x0869200b,
+ 0x0869d125,
+ 0x0873f800,
+ 0x08755002,
+ 0x08757001,
+ 0x0875904d,
+ 0x08794007,
+ 0x087a300a,
+ 0x087ad015,
+ 0x087c1003,
+ 0x087c5025,
+ 0x087e6013,
+ 0x087fb808,
+ 0x08800800,
+ 0x0881c00e,
+ 0x08827003,
+ 0x08838000,
+ 0x08839801,
+ 0x0883b00b,
+ 0x08859803,
+ 0x0885c801,
+ 0x0885e800,
+ 0x0886100d,
+ 0x08874806,
+ 0x0887d008,
+ 0x08893804,
+ 0x08896808,
+ 0x088a4007,
+ 0x088b9800,
+ 0x088bb80a,
+ 0x088db008,
+ 0x088e4803,
+ 0x088e7800,
+ 0x088f0000,
+ 0x088fa80a,
+ 0x08909000,
+ 0x08917802,
+ 0x0891a000,
+ 0x0891b001,
+ 0x0891f000,
+ 0x0892083e,
+ 0x08943800,
+ 0x08944800,
+ 0x08947000,
+ 0x0894f000,
+ 0x08955005,
+ 0x0896f800,
+ 0x0897180c,
+ 0x0897d007,
+ 0x08982000,
+ 0x08986801,
+ 0x08988801,
+ 0x08994800,
+ 0x08998800,
+ 0x0899a000,
+ 0x0899d002,
+ 0x0899f000,
+ 0x089a0000,
+ 0x089a2801,
+ 0x089a4801,
+ 0x089a7001,
+ 0x089a880b,
+ 0x089b209b,
+ 0x08a1c007,
+ 0x08a21002,
+ 0x08a23000,
+ 0x08a2e000,
+ 0x08a2f000,
+ 0x08a3101d,
+ 0x08a58000,
+ 0x08a59805,
+ 0x08a5d000,
+ 0x08a5e800,
+ 0x08a5f801,
+ 0x08a61001,
+ 0x08a64007,
+ 0x08a6d0a5,
+ 0x08ad7800,
+ 0x08ad9005,
+ 0x08ade001,
+ 0x08adf801,
+ 0x08aee023,
+ 0x08b19807,
+ 0x08b1e800,
+ 0x08b1f801,
+ 0x08b2280a,
+ 0x08b2d005,
+ 0x08b36812,
+ 0x08b55800,
+ 0x08b56800,
+ 0x08b58005,
+ 0x08b5b800,
+ 0x08b5d005,
+ 0x08b65035,
+ 0x08b8d804,
+ 0x08b91003,
+ 0x08b93808,
+ 0x08ba38b8,
+ 0x08c17808,
+ 0x08c1c801,
+ 0x08c1e063,
+ 0x08c7980b,
+ 0x08c83801,
+ 0x08c85001,
+ 0x08c8a000,
+ 0x08c8b800,
+ 0x08c98000,
+ 0x08c9b000,
+ 0x08c9c803,
+ 0x08c9f000,
+ 0x08ca1800,
+ 0x08ca3808,
+ 0x08cad045,
+ 0x08cd4001,
+ 0x08cea007,
+ 0x08cf0000,
+ 0x08cf281a,
+ 0x08d00809,
+ 0x08d19805,
+ 0x08d1d803,
+ 0x08d23808,
+ 0x08d28805,
+ 0x08d2c802,
+ 0x08d4500c,
+ 0x08d4c001,
+ 0x08d5180c,
+ 0x08d7c806,
+ 0x08d850f5,
+ 0x08e04800,
+ 0x08e1800d,
+ 0x08e1f800,
+ 0x08e23009,
+ 0x08e36802,
+ 0x08e48018,
+ 0x08e55006,
+ 0x08e59001,
+ 0x08e5a84a,
+ 0x08e83800,
+ 0x08e85000,
+ 0x08e98814,
+ 0x08ea3808,
+ 0x08ead005,
+ 0x08eb3000,
+ 0x08eb4800,
+ 0x08ec7803,
+ 0x08eca800,
+ 0x08ecb800,
+ 0x08ecc806,
+ 0x08ed5135,
+ 0x08f79801,
+ 0x08f7c808,
+ 0x08f88800,
+ 0x08f9b007,
+ 0x08fa0000,
+ 0x08fa1000,
+ 0x08fad055,
+ 0x08fd880e,
+ 0x08ff900c,
+ 0x091cd065,
+ 0x09237800,
+ 0x0923a80a,
+ 0x092a27ff,
+ 0x096a224b,
+ 0x097f980c,
+ 0x09a18010,
+ 0x09a23fff,
+ 0x09e23fb8,
+ 0x0a323fff,
+ 0x0a723fff,
+ 0x0ab23fff,
+ 0x0af23fff,
+ 0x0b3239b8,
+ 0x0b51c806,
+ 0x0b52f800,
+ 0x0b535003,
+ 0x0b55f800,
+ 0x0b565005,
+ 0x0b577006,
+ 0x0b57b009,
+ 0x0b598006,
+ 0x0b5a3009,
+ 0x0b5ad000,
+ 0x0b5b1000,
+ 0x0b5bc004,
+ 0x0b5c82af,
+ 0x0b74d864,
+ 0x0b7a5804,
+ 0x0b7c400a,
+ 0x0b7d003f,
+ 0x0b7f200b,
+ 0x0b7f900d,
+ 0x0c3fc007,
+ 0x0c66b029,
+ 0x0c684fff,
+ 0x0ca84fff,
+ 0x0ce84fff,
+ 0x0d284fff,
+ 0x0d684ae6,
+ 0x0d7fa000,
+ 0x0d7fe000,
+ 0x0d7ff800,
+ 0x0d89180e,
+ 0x0d89981c,
+ 0x0d8a9801,
+ 0x0d8ab00d,
+ 0x0d8b4007,
+ 0x0d97e7ff,
+ 0x0dd7e103,
+ 0x0de35804,
+ 0x0de3e802,
+ 0x0de44806,
+ 0x0de4d001,
+ 0x0de4e801,
+ 0x0de507ff,
+ 0x0e2507ff,
+ 0x0e6502af,
+ 0x0e7e203b,
+ 0x0e87b009,
+ 0x0e893801,
+ 0x0e8b2800,
+ 0x0e8b3802,
+ 0x0e8b7014,
+ 0x0e8c2806,
+ 0x0e8d5003,
+ 0x0e8f5814,
+ 0x0e921002,
+ 0x0e923079,
+ 0x0e96a00b,
+ 0x0e97a00b,
+ 0x0e9ab808,
+ 0x0e9bc886,
+ 0x0ea2a800,
+ 0x0ea4e800,
+ 0x0ea50001,
+ 0x0ea51801,
+ 0x0ea53801,
+ 0x0ea56800,
+ 0x0ea5d000,
+ 0x0ea5e000,
+ 0x0ea62000,
+ 0x0ea83000,
+ 0x0ea85801,
+ 0x0ea8a800,
+ 0x0ea8e800,
+ 0x0ea9d000,
+ 0x0ea9f800,
+ 0x0eaa2800,
+ 0x0eaa3802,
+ 0x0eaa8800,
+ 0x0eb53001,
+ 0x0ebe6001,
+ 0x0ed00036,
+ 0x0ed1d831,
+ 0x0ed3a800,
+ 0x0ed42000,
+ 0x0ed46473,
+ 0x0ef8f805,
+ 0x0ef95904,
+ 0x0f037091,
+ 0x0f096809,
+ 0x0f09f001,
+ 0x0f0a5003,
+ 0x0f0a813f,
+ 0x0f157011,
+ 0x0f176003,
+ 0x0f17d004,
+ 0x0f1801cf,
+ 0x0f276003,
+ 0x0f27d2e5,
+ 0x0f3f3800,
+ 0x0f3f6000,
+ 0x0f3f7800,
+ 0x0f3ff800,
+ 0x0f462801,
+ 0x0f46802f,
+ 0x0f4a2006,
+ 0x0f4a6003,
+ 0x0f4ad003,
+ 0x0f4b0310,
+ 0x0f65a84b,
+ 0x0f69f0c1,
+ 0x0f702000,
+ 0x0f710000,
+ 0x0f711800,
+ 0x0f712801,
+ 0x0f714000,
+ 0x0f719800,
+ 0x0f71c000,
+ 0x0f71d000,
+ 0x0f71e005,
+ 0x0f721803,
+ 0x0f724000,
+ 0x0f725000,
+ 0x0f726000,
+ 0x0f728000,
+ 0x0f729800,
+ 0x0f72a801,
+ 0x0f72c000,
+ 0x0f72d000,
+ 0x0f72e000,
+ 0x0f72f000,
+ 0x0f730000,
+ 0x0f731800,
+ 0x0f732801,
+ 0x0f735800,
+ 0x0f739800,
+ 0x0f73c000,
+ 0x0f73e800,
+ 0x0f73f800,
+ 0x0f745000,
+ 0x0f74e004,
+ 0x0f752000,
+ 0x0f755000,
+ 0x0f75e033,
+ 0x0f77910d,
+ 0x0f816003,
+ 0x0f84a00b,
+ 0x0f857801,
+ 0x0f860000,
+ 0x0f868000,
+ 0x0f87b009,
+ 0x0f8d7037,
+ 0x0f90180c,
+ 0x0f91e003,
+ 0x0f924806,
+ 0x0f92900d,
+ 0x0f933099,
+ 0x0fb6c003,
+ 0x0fb76802,
+ 0x0fb7e802,
+ 0x0fbbb803,
+ 0x0fbed005,
+ 0x0fbf6003,
+ 0x0fbf880e,
+ 0x0fc06003,
+ 0x0fc24007,
+ 0x0fc2d005,
+ 0x0fc44007,
+ 0x0fc57001,
+ 0x0fc5904d,
+ 0x0fd2a00b,
+ 0x0fd37001,
+ 0x0fd3e802,
+ 0x0fd44806,
+ 0x0fd5f000,
+ 0x0fd63007,
+ 0x0fd6e003,
+ 0x0fd74806,
+ 0x0fd7c806,
+ 0x0fdc9800,
+ 0x0fde5824,
+ 0x0fdfd405,
+ 0x1537001f,
+ 0x15b9d005,
+ 0x15c0f001,
+ 0x1675100d,
+ 0x175f0fff,
+ 0x179f0c1e,
+ 0x17d0f5e1,
+ 0x189a5804};
+
+/// At the end of the valid Unicode code points space a lot of code points are
+/// either reserved or a noncharacter. Adding all these entries to the
+/// lookup table would add 446 entries to the table (in Unicode 14).
+/// Instead the only the start of the region is stored, every code point in
+/// this region needs to be escaped.
+inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0;
+
+/// Returns whether the code unit needs to be escaped.
+///
+/// \pre The code point is a valid Unicode code point.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept {
+ // Since __unallocated_region_lower_bound contains the unshifted range do the
+ // comparison without shifting.
+ if (__code_point >= __unallocated_region_lower_bound)
+ return true;
+
+ ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
+ if (__i == 0)
+ return false;
+
+ --__i;
+ uint32_t __upper_bound = (__entries[__i] >> 11) + (__entries[__i] & 0x7ffu);
+ return __code_point <= __upper_bound;
+}
+
+} // namespace __escaped_output_table
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
diff --git a/libcxx/include/__format/extended_grapheme_cluster_table.h b/libcxx/include/__format/extended_grapheme_cluster_table.h
index 00cd0e91cd15..1ffcfeb54968 100644
--- a/libcxx/include/__format/extended_grapheme_cluster_table.h
+++ b/libcxx/include/__format/extended_grapheme_cluster_table.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// WARNING, this entire header is generated by
-// utiles/generate_extended_grapheme_cluster_table.py
+// utils/generate_extended_grapheme_cluster_table.py
// DO NOT MODIFY!
// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
@@ -61,7 +61,7 @@
#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
-#include <__algorithm/upper_bound.h>
+#include <__algorithm/ranges_upper_bound.h>
#include <__config>
#include <__iterator/access.h>
#include <cstddef>
@@ -111,7 +111,7 @@ enum class __property : uint8_t {
/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
///
/// The data has 3 values
-/// - bits [0, 3] The property. One of the values generated form the datafiles
+/// - bits [0, 3] The property. One of the values generated from the datafiles
/// of \ref __property
/// - bits [4, 10] The size of the range.
/// - bits [11, 31] The lower bound code point of the range. The upper bound of
@@ -124,177 +124,1506 @@ enum class __property : uint8_t {
/// this approach uses less space for the data and is about 4% faster in the
/// following benchmark.
/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
-inline constexpr uint32_t __entries[1480] = {
- 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003,
- 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2,
- 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808,
- 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842,
- 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a,
- 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802,
- 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802,
- 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822,
- 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812,
- 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012,
- 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002,
- 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a,
- 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802,
- 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a,
- 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a,
- 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a,
- 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802,
- 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802,
- 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32,
- 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012,
- 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c,
- 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012,
- 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001,
- 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002,
- 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062,
- 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a,
- 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a,
- 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012,
- 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012,
- 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2,
- 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202,
- 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3,
- 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713,
- 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003,
- 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003,
- 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2,
- 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012,
- 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a,
- 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022,
- 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852,
- 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002,
- 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002,
- 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7,
- 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006,
- 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7,
- 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006,
- 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7,
- 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006,
- 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7,
- 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006,
- 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7,
- 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006,
- 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7,
- 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006,
- 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7,
- 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006,
- 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7,
- 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006,
- 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7,
- 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006,
- 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7,
- 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006,
- 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7,
- 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006,
- 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7,
- 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006,
- 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7,
- 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006,
- 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7,
- 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006,
- 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7,
- 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006,
- 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7,
- 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006,
- 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7,
- 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006,
- 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7,
- 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006,
- 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7,
- 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006,
- 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7,
- 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006,
- 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7,
- 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006,
- 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7,
- 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006,
- 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7,
- 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006,
- 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7,
- 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006,
- 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7,
- 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006,
- 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7,
- 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006,
- 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7,
- 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006,
- 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7,
- 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006,
- 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7,
- 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006,
- 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7,
- 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006,
- 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7,
- 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006,
- 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7,
- 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006,
- 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7,
- 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006,
- 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7,
- 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006,
- 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7,
- 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006,
- 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7,
- 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006,
- 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7,
- 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006,
- 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7,
- 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006,
- 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7,
- 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006,
- 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7,
- 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006,
- 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7,
- 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006,
- 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7,
- 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006,
- 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7,
- 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006,
- 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7,
- 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006,
- 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7,
- 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2,
- 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032,
- 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802,
- 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a,
- 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a,
- 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a,
- 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802,
- 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a,
- 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a,
- 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002,
- 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032,
- 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802,
- 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802,
- 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002,
- 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a,
- 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852,
- 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2,
- 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a,
- 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862,
- 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812,
- 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a,
- 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042,
- 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002,
- 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002,
- 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013,
- 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033,
- 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3,
- 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073,
- 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3,
- 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1,
- 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1,
- 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1,
- 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1,
- 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1};
+inline constexpr uint32_t __entries[1496] = {
+ 0x00000091,
+ 0x00005005,
+ 0x00005811,
+ 0x00006800,
+ 0x00007111,
+ 0x0003fa01,
+ 0x00054803,
+ 0x00056801,
+ 0x00057003,
+ 0x001806f2,
+ 0x00241862,
+ 0x002c8ac2,
+ 0x002df802,
+ 0x002e0812,
+ 0x002e2012,
+ 0x002e3802,
+ 0x00300058,
+ 0x003080a2,
+ 0x0030e001,
+ 0x00325942,
+ 0x00338002,
+ 0x0036b062,
+ 0x0036e808,
+ 0x0036f852,
+ 0x00373812,
+ 0x00375032,
+ 0x00387808,
+ 0x00388802,
+ 0x003981a2,
+ 0x003d30a2,
+ 0x003f5882,
+ 0x003fe802,
+ 0x0040b032,
+ 0x0040d882,
+ 0x00412822,
+ 0x00414842,
+ 0x0042c822,
+ 0x00448018,
+ 0x0044c072,
+ 0x00465172,
+ 0x00471008,
+ 0x004719f2,
+ 0x0048180a,
+ 0x0049d002,
+ 0x0049d80a,
+ 0x0049e002,
+ 0x0049f02a,
+ 0x004a0872,
+ 0x004a483a,
+ 0x004a6802,
+ 0x004a701a,
+ 0x004a8862,
+ 0x004b1012,
+ 0x004c0802,
+ 0x004c101a,
+ 0x004de002,
+ 0x004df002,
+ 0x004df81a,
+ 0x004e0832,
+ 0x004e381a,
+ 0x004e581a,
+ 0x004e6802,
+ 0x004eb802,
+ 0x004f1012,
+ 0x004ff002,
+ 0x00500812,
+ 0x0050180a,
+ 0x0051e002,
+ 0x0051f02a,
+ 0x00520812,
+ 0x00523812,
+ 0x00525822,
+ 0x00528802,
+ 0x00538012,
+ 0x0053a802,
+ 0x00540812,
+ 0x0054180a,
+ 0x0055e002,
+ 0x0055f02a,
+ 0x00560842,
+ 0x00563812,
+ 0x0056480a,
+ 0x0056581a,
+ 0x00566802,
+ 0x00571012,
+ 0x0057d052,
+ 0x00580802,
+ 0x0058101a,
+ 0x0059e002,
+ 0x0059f012,
+ 0x005a000a,
+ 0x005a0832,
+ 0x005a381a,
+ 0x005a581a,
+ 0x005a6802,
+ 0x005aa822,
+ 0x005b1012,
+ 0x005c1002,
+ 0x005df002,
+ 0x005df80a,
+ 0x005e0002,
+ 0x005e081a,
+ 0x005e302a,
+ 0x005e502a,
+ 0x005e6802,
+ 0x005eb802,
+ 0x00600002,
+ 0x0060082a,
+ 0x00602002,
+ 0x0061e002,
+ 0x0061f022,
+ 0x0062083a,
+ 0x00623022,
+ 0x00625032,
+ 0x0062a812,
+ 0x00631012,
+ 0x00640802,
+ 0x0064101a,
+ 0x0065e002,
+ 0x0065f00a,
+ 0x0065f802,
+ 0x0066001a,
+ 0x00661002,
+ 0x0066181a,
+ 0x00663002,
+ 0x0066381a,
+ 0x0066501a,
+ 0x00666012,
+ 0x0066a812,
+ 0x00671012,
+ 0x0067980a,
+ 0x00680012,
+ 0x0068101a,
+ 0x0069d812,
+ 0x0069f002,
+ 0x0069f81a,
+ 0x006a0832,
+ 0x006a302a,
+ 0x006a502a,
+ 0x006a6802,
+ 0x006a7008,
+ 0x006ab802,
+ 0x006b1012,
+ 0x006c0802,
+ 0x006c101a,
+ 0x006e5002,
+ 0x006e7802,
+ 0x006e801a,
+ 0x006e9022,
+ 0x006eb002,
+ 0x006ec06a,
+ 0x006ef802,
+ 0x006f901a,
+ 0x00718802,
+ 0x0071980a,
+ 0x0071a062,
+ 0x00723872,
+ 0x00758802,
+ 0x0075980a,
+ 0x0075a082,
+ 0x00764062,
+ 0x0078c012,
+ 0x0079a802,
+ 0x0079b802,
+ 0x0079c802,
+ 0x0079f01a,
+ 0x007b88d2,
+ 0x007bf80a,
+ 0x007c0042,
+ 0x007c3012,
+ 0x007c68a2,
+ 0x007cca32,
+ 0x007e3002,
+ 0x00816832,
+ 0x0081880a,
+ 0x00819052,
+ 0x0081c812,
+ 0x0081d81a,
+ 0x0081e812,
+ 0x0082b01a,
+ 0x0082c012,
+ 0x0082f022,
+ 0x00838832,
+ 0x00841002,
+ 0x0084200a,
+ 0x00842812,
+ 0x00846802,
+ 0x0084e802,
+ 0x008805f4,
+ 0x008b047c,
+ 0x008d457b,
+ 0x009ae822,
+ 0x00b89022,
+ 0x00b8a80a,
+ 0x00b99012,
+ 0x00b9a00a,
+ 0x00ba9012,
+ 0x00bb9012,
+ 0x00bda012,
+ 0x00bdb00a,
+ 0x00bdb862,
+ 0x00bdf07a,
+ 0x00be3002,
+ 0x00be381a,
+ 0x00be48a2,
+ 0x00bee802,
+ 0x00c05822,
+ 0x00c07001,
+ 0x00c07802,
+ 0x00c42812,
+ 0x00c54802,
+ 0x00c90022,
+ 0x00c9183a,
+ 0x00c93812,
+ 0x00c9482a,
+ 0x00c9801a,
+ 0x00c99002,
+ 0x00c9985a,
+ 0x00c9c822,
+ 0x00d0b812,
+ 0x00d0c81a,
+ 0x00d0d802,
+ 0x00d2a80a,
+ 0x00d2b002,
+ 0x00d2b80a,
+ 0x00d2c062,
+ 0x00d30002,
+ 0x00d31002,
+ 0x00d32872,
+ 0x00d3685a,
+ 0x00d39892,
+ 0x00d3f802,
+ 0x00d581e2,
+ 0x00d80032,
+ 0x00d8200a,
+ 0x00d9a062,
+ 0x00d9d80a,
+ 0x00d9e002,
+ 0x00d9e84a,
+ 0x00da1002,
+ 0x00da181a,
+ 0x00db5882,
+ 0x00dc0012,
+ 0x00dc100a,
+ 0x00dd080a,
+ 0x00dd1032,
+ 0x00dd301a,
+ 0x00dd4012,
+ 0x00dd500a,
+ 0x00dd5822,
+ 0x00df3002,
+ 0x00df380a,
+ 0x00df4012,
+ 0x00df502a,
+ 0x00df6802,
+ 0x00df700a,
+ 0x00df7822,
+ 0x00df901a,
+ 0x00e1207a,
+ 0x00e16072,
+ 0x00e1a01a,
+ 0x00e1b012,
+ 0x00e68022,
+ 0x00e6a0c2,
+ 0x00e7080a,
+ 0x00e71062,
+ 0x00e76802,
+ 0x00e7a002,
+ 0x00e7b80a,
+ 0x00e7c012,
+ 0x00ee03f2,
+ 0x01005801,
+ 0x01006002,
+ 0x0100680d,
+ 0x01007011,
+ 0x01014061,
+ 0x0101e003,
+ 0x01024803,
+ 0x010300f1,
+ 0x01068202,
+ 0x01091003,
+ 0x0109c803,
+ 0x010ca053,
+ 0x010d4813,
+ 0x0118d013,
+ 0x01194003,
+ 0x011c4003,
+ 0x011e7803,
+ 0x011f48a3,
+ 0x011fc023,
+ 0x01261003,
+ 0x012d5013,
+ 0x012db003,
+ 0x012e0003,
+ 0x012fd833,
+ 0x01300053,
+ 0x013038b3,
+ 0x0130a713,
+ 0x01348753,
+ 0x013840a3,
+ 0x0138a003,
+ 0x0138b003,
+ 0x0138e803,
+ 0x01390803,
+ 0x01394003,
+ 0x01399813,
+ 0x013a2003,
+ 0x013a3803,
+ 0x013a6003,
+ 0x013a7003,
+ 0x013a9823,
+ 0x013ab803,
+ 0x013b1843,
+ 0x013ca823,
+ 0x013d0803,
+ 0x013d8003,
+ 0x013df803,
+ 0x0149a013,
+ 0x01582823,
+ 0x0158d813,
+ 0x015a8003,
+ 0x015aa803,
+ 0x01677822,
+ 0x016bf802,
+ 0x016f01f2,
+ 0x01815052,
+ 0x01818003,
+ 0x0181e803,
+ 0x0184c812,
+ 0x0194b803,
+ 0x0194c803,
+ 0x05337832,
+ 0x0533a092,
+ 0x0534f012,
+ 0x05378012,
+ 0x05401002,
+ 0x05403002,
+ 0x05405802,
+ 0x0541181a,
+ 0x05412812,
+ 0x0541380a,
+ 0x05416002,
+ 0x0544001a,
+ 0x0545a0fa,
+ 0x05462012,
+ 0x05470112,
+ 0x0547f802,
+ 0x05493072,
+ 0x054a38a2,
+ 0x054a901a,
+ 0x054b01c4,
+ 0x054c0022,
+ 0x054c180a,
+ 0x054d9802,
+ 0x054da01a,
+ 0x054db032,
+ 0x054dd01a,
+ 0x054de012,
+ 0x054df02a,
+ 0x054f2802,
+ 0x05514852,
+ 0x0551781a,
+ 0x05518812,
+ 0x0551981a,
+ 0x0551a812,
+ 0x05521802,
+ 0x05526002,
+ 0x0552680a,
+ 0x0553e002,
+ 0x05558002,
+ 0x05559022,
+ 0x0555b812,
+ 0x0555f012,
+ 0x05560802,
+ 0x0557580a,
+ 0x05576012,
+ 0x0557701a,
+ 0x0557a80a,
+ 0x0557b002,
+ 0x055f181a,
+ 0x055f2802,
+ 0x055f301a,
+ 0x055f4002,
+ 0x055f481a,
+ 0x055f600a,
+ 0x055f6802,
+ 0x05600006,
+ 0x056009a7,
+ 0x0560e006,
+ 0x0560e9a7,
+ 0x0561c006,
+ 0x0561c9a7,
+ 0x0562a006,
+ 0x0562a9a7,
+ 0x05638006,
+ 0x056389a7,
+ 0x05646006,
+ 0x056469a7,
+ 0x05654006,
+ 0x056549a7,
+ 0x05662006,
+ 0x056629a7,
+ 0x05670006,
+ 0x056709a7,
+ 0x0567e006,
+ 0x0567e9a7,
+ 0x0568c006,
+ 0x0568c9a7,
+ 0x0569a006,
+ 0x0569a9a7,
+ 0x056a8006,
+ 0x056a89a7,
+ 0x056b6006,
+ 0x056b69a7,
+ 0x056c4006,
+ 0x056c49a7,
+ 0x056d2006,
+ 0x056d29a7,
+ 0x056e0006,
+ 0x056e09a7,
+ 0x056ee006,
+ 0x056ee9a7,
+ 0x056fc006,
+ 0x056fc9a7,
+ 0x0570a006,
+ 0x0570a9a7,
+ 0x05718006,
+ 0x057189a7,
+ 0x05726006,
+ 0x057269a7,
+ 0x05734006,
+ 0x057349a7,
+ 0x05742006,
+ 0x057429a7,
+ 0x05750006,
+ 0x057509a7,
+ 0x0575e006,
+ 0x0575e9a7,
+ 0x0576c006,
+ 0x0576c9a7,
+ 0x0577a006,
+ 0x0577a9a7,
+ 0x05788006,
+ 0x057889a7,
+ 0x05796006,
+ 0x057969a7,
+ 0x057a4006,
+ 0x057a49a7,
+ 0x057b2006,
+ 0x057b29a7,
+ 0x057c0006,
+ 0x057c09a7,
+ 0x057ce006,
+ 0x057ce9a7,
+ 0x057dc006,
+ 0x057dc9a7,
+ 0x057ea006,
+ 0x057ea9a7,
+ 0x057f8006,
+ 0x057f89a7,
+ 0x05806006,
+ 0x058069a7,
+ 0x05814006,
+ 0x058149a7,
+ 0x05822006,
+ 0x058229a7,
+ 0x05830006,
+ 0x058309a7,
+ 0x0583e006,
+ 0x0583e9a7,
+ 0x0584c006,
+ 0x0584c9a7,
+ 0x0585a006,
+ 0x0585a9a7,
+ 0x05868006,
+ 0x058689a7,
+ 0x05876006,
+ 0x058769a7,
+ 0x05884006,
+ 0x058849a7,
+ 0x05892006,
+ 0x058929a7,
+ 0x058a0006,
+ 0x058a09a7,
+ 0x058ae006,
+ 0x058ae9a7,
+ 0x058bc006,
+ 0x058bc9a7,
+ 0x058ca006,
+ 0x058ca9a7,
+ 0x058d8006,
+ 0x058d89a7,
+ 0x058e6006,
+ 0x058e69a7,
+ 0x058f4006,
+ 0x058f49a7,
+ 0x05902006,
+ 0x059029a7,
+ 0x05910006,
+ 0x059109a7,
+ 0x0591e006,
+ 0x0591e9a7,
+ 0x0592c006,
+ 0x0592c9a7,
+ 0x0593a006,
+ 0x0593a9a7,
+ 0x05948006,
+ 0x059489a7,
+ 0x05956006,
+ 0x059569a7,
+ 0x05964006,
+ 0x059649a7,
+ 0x05972006,
+ 0x059729a7,
+ 0x05980006,
+ 0x059809a7,
+ 0x0598e006,
+ 0x0598e9a7,
+ 0x0599c006,
+ 0x0599c9a7,
+ 0x059aa006,
+ 0x059aa9a7,
+ 0x059b8006,
+ 0x059b89a7,
+ 0x059c6006,
+ 0x059c69a7,
+ 0x059d4006,
+ 0x059d49a7,
+ 0x059e2006,
+ 0x059e29a7,
+ 0x059f0006,
+ 0x059f09a7,
+ 0x059fe006,
+ 0x059fe9a7,
+ 0x05a0c006,
+ 0x05a0c9a7,
+ 0x05a1a006,
+ 0x05a1a9a7,
+ 0x05a28006,
+ 0x05a289a7,
+ 0x05a36006,
+ 0x05a369a7,
+ 0x05a44006,
+ 0x05a449a7,
+ 0x05a52006,
+ 0x05a529a7,
+ 0x05a60006,
+ 0x05a609a7,
+ 0x05a6e006,
+ 0x05a6e9a7,
+ 0x05a7c006,
+ 0x05a7c9a7,
+ 0x05a8a006,
+ 0x05a8a9a7,
+ 0x05a98006,
+ 0x05a989a7,
+ 0x05aa6006,
+ 0x05aa69a7,
+ 0x05ab4006,
+ 0x05ab49a7,
+ 0x05ac2006,
+ 0x05ac29a7,
+ 0x05ad0006,
+ 0x05ad09a7,
+ 0x05ade006,
+ 0x05ade9a7,
+ 0x05aec006,
+ 0x05aec9a7,
+ 0x05afa006,
+ 0x05afa9a7,
+ 0x05b08006,
+ 0x05b089a7,
+ 0x05b16006,
+ 0x05b169a7,
+ 0x05b24006,
+ 0x05b249a7,
+ 0x05b32006,
+ 0x05b329a7,
+ 0x05b40006,
+ 0x05b409a7,
+ 0x05b4e006,
+ 0x05b4e9a7,
+ 0x05b5c006,
+ 0x05b5c9a7,
+ 0x05b6a006,
+ 0x05b6a9a7,
+ 0x05b78006,
+ 0x05b789a7,
+ 0x05b86006,
+ 0x05b869a7,
+ 0x05b94006,
+ 0x05b949a7,
+ 0x05ba2006,
+ 0x05ba29a7,
+ 0x05bb0006,
+ 0x05bb09a7,
+ 0x05bbe006,
+ 0x05bbe9a7,
+ 0x05bcc006,
+ 0x05bcc9a7,
+ 0x05bda006,
+ 0x05bda9a7,
+ 0x05be8006,
+ 0x05be89a7,
+ 0x05bf6006,
+ 0x05bf69a7,
+ 0x05c04006,
+ 0x05c049a7,
+ 0x05c12006,
+ 0x05c129a7,
+ 0x05c20006,
+ 0x05c209a7,
+ 0x05c2e006,
+ 0x05c2e9a7,
+ 0x05c3c006,
+ 0x05c3c9a7,
+ 0x05c4a006,
+ 0x05c4a9a7,
+ 0x05c58006,
+ 0x05c589a7,
+ 0x05c66006,
+ 0x05c669a7,
+ 0x05c74006,
+ 0x05c749a7,
+ 0x05c82006,
+ 0x05c829a7,
+ 0x05c90006,
+ 0x05c909a7,
+ 0x05c9e006,
+ 0x05c9e9a7,
+ 0x05cac006,
+ 0x05cac9a7,
+ 0x05cba006,
+ 0x05cba9a7,
+ 0x05cc8006,
+ 0x05cc89a7,
+ 0x05cd6006,
+ 0x05cd69a7,
+ 0x05ce4006,
+ 0x05ce49a7,
+ 0x05cf2006,
+ 0x05cf29a7,
+ 0x05d00006,
+ 0x05d009a7,
+ 0x05d0e006,
+ 0x05d0e9a7,
+ 0x05d1c006,
+ 0x05d1c9a7,
+ 0x05d2a006,
+ 0x05d2a9a7,
+ 0x05d38006,
+ 0x05d389a7,
+ 0x05d46006,
+ 0x05d469a7,
+ 0x05d54006,
+ 0x05d549a7,
+ 0x05d62006,
+ 0x05d629a7,
+ 0x05d70006,
+ 0x05d709a7,
+ 0x05d7e006,
+ 0x05d7e9a7,
+ 0x05d8c006,
+ 0x05d8c9a7,
+ 0x05d9a006,
+ 0x05d9a9a7,
+ 0x05da8006,
+ 0x05da89a7,
+ 0x05db6006,
+ 0x05db69a7,
+ 0x05dc4006,
+ 0x05dc49a7,
+ 0x05dd2006,
+ 0x05dd29a7,
+ 0x05de0006,
+ 0x05de09a7,
+ 0x05dee006,
+ 0x05dee9a7,
+ 0x05dfc006,
+ 0x05dfc9a7,
+ 0x05e0a006,
+ 0x05e0a9a7,
+ 0x05e18006,
+ 0x05e189a7,
+ 0x05e26006,
+ 0x05e269a7,
+ 0x05e34006,
+ 0x05e349a7,
+ 0x05e42006,
+ 0x05e429a7,
+ 0x05e50006,
+ 0x05e509a7,
+ 0x05e5e006,
+ 0x05e5e9a7,
+ 0x05e6c006,
+ 0x05e6c9a7,
+ 0x05e7a006,
+ 0x05e7a9a7,
+ 0x05e88006,
+ 0x05e889a7,
+ 0x05e96006,
+ 0x05e969a7,
+ 0x05ea4006,
+ 0x05ea49a7,
+ 0x05eb2006,
+ 0x05eb29a7,
+ 0x05ec0006,
+ 0x05ec09a7,
+ 0x05ece006,
+ 0x05ece9a7,
+ 0x05edc006,
+ 0x05edc9a7,
+ 0x05eea006,
+ 0x05eea9a7,
+ 0x05ef8006,
+ 0x05ef89a7,
+ 0x05f06006,
+ 0x05f069a7,
+ 0x05f14006,
+ 0x05f149a7,
+ 0x05f22006,
+ 0x05f229a7,
+ 0x05f30006,
+ 0x05f309a7,
+ 0x05f3e006,
+ 0x05f3e9a7,
+ 0x05f4c006,
+ 0x05f4c9a7,
+ 0x05f5a006,
+ 0x05f5a9a7,
+ 0x05f68006,
+ 0x05f689a7,
+ 0x05f76006,
+ 0x05f769a7,
+ 0x05f84006,
+ 0x05f849a7,
+ 0x05f92006,
+ 0x05f929a7,
+ 0x05fa0006,
+ 0x05fa09a7,
+ 0x05fae006,
+ 0x05fae9a7,
+ 0x05fbc006,
+ 0x05fbc9a7,
+ 0x05fca006,
+ 0x05fca9a7,
+ 0x05fd8006,
+ 0x05fd89a7,
+ 0x05fe6006,
+ 0x05fe69a7,
+ 0x05ff4006,
+ 0x05ff49a7,
+ 0x06002006,
+ 0x060029a7,
+ 0x06010006,
+ 0x060109a7,
+ 0x0601e006,
+ 0x0601e9a7,
+ 0x0602c006,
+ 0x0602c9a7,
+ 0x0603a006,
+ 0x0603a9a7,
+ 0x06048006,
+ 0x060489a7,
+ 0x06056006,
+ 0x060569a7,
+ 0x06064006,
+ 0x060649a7,
+ 0x06072006,
+ 0x060729a7,
+ 0x06080006,
+ 0x060809a7,
+ 0x0608e006,
+ 0x0608e9a7,
+ 0x0609c006,
+ 0x0609c9a7,
+ 0x060aa006,
+ 0x060aa9a7,
+ 0x060b8006,
+ 0x060b89a7,
+ 0x060c6006,
+ 0x060c69a7,
+ 0x060d4006,
+ 0x060d49a7,
+ 0x060e2006,
+ 0x060e29a7,
+ 0x060f0006,
+ 0x060f09a7,
+ 0x060fe006,
+ 0x060fe9a7,
+ 0x0610c006,
+ 0x0610c9a7,
+ 0x0611a006,
+ 0x0611a9a7,
+ 0x06128006,
+ 0x061289a7,
+ 0x06136006,
+ 0x061369a7,
+ 0x06144006,
+ 0x061449a7,
+ 0x06152006,
+ 0x061529a7,
+ 0x06160006,
+ 0x061609a7,
+ 0x0616e006,
+ 0x0616e9a7,
+ 0x0617c006,
+ 0x0617c9a7,
+ 0x0618a006,
+ 0x0618a9a7,
+ 0x06198006,
+ 0x061989a7,
+ 0x061a6006,
+ 0x061a69a7,
+ 0x061b4006,
+ 0x061b49a7,
+ 0x061c2006,
+ 0x061c29a7,
+ 0x061d0006,
+ 0x061d09a7,
+ 0x061de006,
+ 0x061de9a7,
+ 0x061ec006,
+ 0x061ec9a7,
+ 0x061fa006,
+ 0x061fa9a7,
+ 0x06208006,
+ 0x062089a7,
+ 0x06216006,
+ 0x062169a7,
+ 0x06224006,
+ 0x062249a7,
+ 0x06232006,
+ 0x062329a7,
+ 0x06240006,
+ 0x062409a7,
+ 0x0624e006,
+ 0x0624e9a7,
+ 0x0625c006,
+ 0x0625c9a7,
+ 0x0626a006,
+ 0x0626a9a7,
+ 0x06278006,
+ 0x062789a7,
+ 0x06286006,
+ 0x062869a7,
+ 0x06294006,
+ 0x062949a7,
+ 0x062a2006,
+ 0x062a29a7,
+ 0x062b0006,
+ 0x062b09a7,
+ 0x062be006,
+ 0x062be9a7,
+ 0x062cc006,
+ 0x062cc9a7,
+ 0x062da006,
+ 0x062da9a7,
+ 0x062e8006,
+ 0x062e89a7,
+ 0x062f6006,
+ 0x062f69a7,
+ 0x06304006,
+ 0x063049a7,
+ 0x06312006,
+ 0x063129a7,
+ 0x06320006,
+ 0x063209a7,
+ 0x0632e006,
+ 0x0632e9a7,
+ 0x0633c006,
+ 0x0633c9a7,
+ 0x0634a006,
+ 0x0634a9a7,
+ 0x06358006,
+ 0x063589a7,
+ 0x06366006,
+ 0x063669a7,
+ 0x06374006,
+ 0x063749a7,
+ 0x06382006,
+ 0x063829a7,
+ 0x06390006,
+ 0x063909a7,
+ 0x0639e006,
+ 0x0639e9a7,
+ 0x063ac006,
+ 0x063ac9a7,
+ 0x063ba006,
+ 0x063ba9a7,
+ 0x063c8006,
+ 0x063c89a7,
+ 0x063d6006,
+ 0x063d69a7,
+ 0x063e4006,
+ 0x063e49a7,
+ 0x063f2006,
+ 0x063f29a7,
+ 0x06400006,
+ 0x064009a7,
+ 0x0640e006,
+ 0x0640e9a7,
+ 0x0641c006,
+ 0x0641c9a7,
+ 0x0642a006,
+ 0x0642a9a7,
+ 0x06438006,
+ 0x064389a7,
+ 0x06446006,
+ 0x064469a7,
+ 0x06454006,
+ 0x064549a7,
+ 0x06462006,
+ 0x064629a7,
+ 0x06470006,
+ 0x064709a7,
+ 0x0647e006,
+ 0x0647e9a7,
+ 0x0648c006,
+ 0x0648c9a7,
+ 0x0649a006,
+ 0x0649a9a7,
+ 0x064a8006,
+ 0x064a89a7,
+ 0x064b6006,
+ 0x064b69a7,
+ 0x064c4006,
+ 0x064c49a7,
+ 0x064d2006,
+ 0x064d29a7,
+ 0x064e0006,
+ 0x064e09a7,
+ 0x064ee006,
+ 0x064ee9a7,
+ 0x064fc006,
+ 0x064fc9a7,
+ 0x0650a006,
+ 0x0650a9a7,
+ 0x06518006,
+ 0x065189a7,
+ 0x06526006,
+ 0x065269a7,
+ 0x06534006,
+ 0x065349a7,
+ 0x06542006,
+ 0x065429a7,
+ 0x06550006,
+ 0x065509a7,
+ 0x0655e006,
+ 0x0655e9a7,
+ 0x0656c006,
+ 0x0656c9a7,
+ 0x0657a006,
+ 0x0657a9a7,
+ 0x06588006,
+ 0x065889a7,
+ 0x06596006,
+ 0x065969a7,
+ 0x065a4006,
+ 0x065a49a7,
+ 0x065b2006,
+ 0x065b29a7,
+ 0x065c0006,
+ 0x065c09a7,
+ 0x065ce006,
+ 0x065ce9a7,
+ 0x065dc006,
+ 0x065dc9a7,
+ 0x065ea006,
+ 0x065ea9a7,
+ 0x065f8006,
+ 0x065f89a7,
+ 0x06606006,
+ 0x066069a7,
+ 0x06614006,
+ 0x066149a7,
+ 0x06622006,
+ 0x066229a7,
+ 0x06630006,
+ 0x066309a7,
+ 0x0663e006,
+ 0x0663e9a7,
+ 0x0664c006,
+ 0x0664c9a7,
+ 0x0665a006,
+ 0x0665a9a7,
+ 0x06668006,
+ 0x066689a7,
+ 0x06676006,
+ 0x066769a7,
+ 0x06684006,
+ 0x066849a7,
+ 0x06692006,
+ 0x066929a7,
+ 0x066a0006,
+ 0x066a09a7,
+ 0x066ae006,
+ 0x066ae9a7,
+ 0x066bc006,
+ 0x066bc9a7,
+ 0x066ca006,
+ 0x066ca9a7,
+ 0x066d8006,
+ 0x066d89a7,
+ 0x066e6006,
+ 0x066e69a7,
+ 0x066f4006,
+ 0x066f49a7,
+ 0x06702006,
+ 0x067029a7,
+ 0x06710006,
+ 0x067109a7,
+ 0x0671e006,
+ 0x0671e9a7,
+ 0x0672c006,
+ 0x0672c9a7,
+ 0x0673a006,
+ 0x0673a9a7,
+ 0x06748006,
+ 0x067489a7,
+ 0x06756006,
+ 0x067569a7,
+ 0x06764006,
+ 0x067649a7,
+ 0x06772006,
+ 0x067729a7,
+ 0x06780006,
+ 0x067809a7,
+ 0x0678e006,
+ 0x0678e9a7,
+ 0x0679c006,
+ 0x0679c9a7,
+ 0x067aa006,
+ 0x067aa9a7,
+ 0x067b8006,
+ 0x067b89a7,
+ 0x067c6006,
+ 0x067c69a7,
+ 0x067d4006,
+ 0x067d49a7,
+ 0x067e2006,
+ 0x067e29a7,
+ 0x067f0006,
+ 0x067f09a7,
+ 0x067fe006,
+ 0x067fe9a7,
+ 0x0680c006,
+ 0x0680c9a7,
+ 0x0681a006,
+ 0x0681a9a7,
+ 0x06828006,
+ 0x068289a7,
+ 0x06836006,
+ 0x068369a7,
+ 0x06844006,
+ 0x068449a7,
+ 0x06852006,
+ 0x068529a7,
+ 0x06860006,
+ 0x068609a7,
+ 0x0686e006,
+ 0x0686e9a7,
+ 0x0687c006,
+ 0x0687c9a7,
+ 0x0688a006,
+ 0x0688a9a7,
+ 0x06898006,
+ 0x068989a7,
+ 0x068a6006,
+ 0x068a69a7,
+ 0x068b4006,
+ 0x068b49a7,
+ 0x068c2006,
+ 0x068c29a7,
+ 0x068d0006,
+ 0x068d09a7,
+ 0x068de006,
+ 0x068de9a7,
+ 0x068ec006,
+ 0x068ec9a7,
+ 0x068fa006,
+ 0x068fa9a7,
+ 0x06908006,
+ 0x069089a7,
+ 0x06916006,
+ 0x069169a7,
+ 0x06924006,
+ 0x069249a7,
+ 0x06932006,
+ 0x069329a7,
+ 0x06940006,
+ 0x069409a7,
+ 0x0694e006,
+ 0x0694e9a7,
+ 0x0695c006,
+ 0x0695c9a7,
+ 0x0696a006,
+ 0x0696a9a7,
+ 0x06978006,
+ 0x069789a7,
+ 0x06986006,
+ 0x069869a7,
+ 0x06994006,
+ 0x069949a7,
+ 0x069a2006,
+ 0x069a29a7,
+ 0x069b0006,
+ 0x069b09a7,
+ 0x069be006,
+ 0x069be9a7,
+ 0x069cc006,
+ 0x069cc9a7,
+ 0x069da006,
+ 0x069da9a7,
+ 0x069e8006,
+ 0x069e89a7,
+ 0x069f6006,
+ 0x069f69a7,
+ 0x06a04006,
+ 0x06a049a7,
+ 0x06a12006,
+ 0x06a129a7,
+ 0x06a20006,
+ 0x06a209a7,
+ 0x06a2e006,
+ 0x06a2e9a7,
+ 0x06a3c006,
+ 0x06a3c9a7,
+ 0x06a4a006,
+ 0x06a4a9a7,
+ 0x06a58006,
+ 0x06a589a7,
+ 0x06a66006,
+ 0x06a669a7,
+ 0x06a74006,
+ 0x06a749a7,
+ 0x06a82006,
+ 0x06a829a7,
+ 0x06a90006,
+ 0x06a909a7,
+ 0x06a9e006,
+ 0x06a9e9a7,
+ 0x06aac006,
+ 0x06aac9a7,
+ 0x06aba006,
+ 0x06aba9a7,
+ 0x06ac8006,
+ 0x06ac89a7,
+ 0x06ad6006,
+ 0x06ad69a7,
+ 0x06ae4006,
+ 0x06ae49a7,
+ 0x06af2006,
+ 0x06af29a7,
+ 0x06b00006,
+ 0x06b009a7,
+ 0x06b0e006,
+ 0x06b0e9a7,
+ 0x06b1c006,
+ 0x06b1c9a7,
+ 0x06b2a006,
+ 0x06b2a9a7,
+ 0x06b38006,
+ 0x06b389a7,
+ 0x06b46006,
+ 0x06b469a7,
+ 0x06b54006,
+ 0x06b549a7,
+ 0x06b62006,
+ 0x06b629a7,
+ 0x06b70006,
+ 0x06b709a7,
+ 0x06b7e006,
+ 0x06b7e9a7,
+ 0x06b8c006,
+ 0x06b8c9a7,
+ 0x06b9a006,
+ 0x06b9a9a7,
+ 0x06ba8006,
+ 0x06ba89a7,
+ 0x06bb6006,
+ 0x06bb69a7,
+ 0x06bc4006,
+ 0x06bc49a7,
+ 0x06bd816c,
+ 0x06be5b0b,
+ 0x07d8f002,
+ 0x07f000f2,
+ 0x07f100f2,
+ 0x07f7f801,
+ 0x07fcf012,
+ 0x07ff80b1,
+ 0x080fe802,
+ 0x08170002,
+ 0x081bb042,
+ 0x08500822,
+ 0x08502812,
+ 0x08506032,
+ 0x0851c022,
+ 0x0851f802,
+ 0x08572812,
+ 0x08692032,
+ 0x08755812,
+ 0x0877e822,
+ 0x087a30a2,
+ 0x087c1032,
+ 0x0880000a,
+ 0x08800802,
+ 0x0880100a,
+ 0x0881c0e2,
+ 0x08838002,
+ 0x08839812,
+ 0x0883f822,
+ 0x0884100a,
+ 0x0885802a,
+ 0x08859832,
+ 0x0885b81a,
+ 0x0885c812,
+ 0x0885e808,
+ 0x08861002,
+ 0x08866808,
+ 0x08880022,
+ 0x08893842,
+ 0x0889600a,
+ 0x08896872,
+ 0x088a281a,
+ 0x088b9802,
+ 0x088c0012,
+ 0x088c100a,
+ 0x088d982a,
+ 0x088db082,
+ 0x088df81a,
+ 0x088e1018,
+ 0x088e4832,
+ 0x088e700a,
+ 0x088e7802,
+ 0x0891602a,
+ 0x08917822,
+ 0x0891901a,
+ 0x0891a002,
+ 0x0891a80a,
+ 0x0891b012,
+ 0x0891f002,
+ 0x08920802,
+ 0x0896f802,
+ 0x0897002a,
+ 0x08971872,
+ 0x08980012,
+ 0x0898101a,
+ 0x0899d812,
+ 0x0899f002,
+ 0x0899f80a,
+ 0x089a0002,
+ 0x089a083a,
+ 0x089a381a,
+ 0x089a582a,
+ 0x089ab802,
+ 0x089b101a,
+ 0x089b3062,
+ 0x089b8042,
+ 0x08a1a82a,
+ 0x08a1c072,
+ 0x08a2001a,
+ 0x08a21022,
+ 0x08a2280a,
+ 0x08a23002,
+ 0x08a2f002,
+ 0x08a58002,
+ 0x08a5881a,
+ 0x08a59852,
+ 0x08a5c80a,
+ 0x08a5d002,
+ 0x08a5d81a,
+ 0x08a5e802,
+ 0x08a5f00a,
+ 0x08a5f812,
+ 0x08a6080a,
+ 0x08a61012,
+ 0x08ad7802,
+ 0x08ad801a,
+ 0x08ad9032,
+ 0x08adc03a,
+ 0x08ade012,
+ 0x08adf00a,
+ 0x08adf812,
+ 0x08aee012,
+ 0x08b1802a,
+ 0x08b19872,
+ 0x08b1d81a,
+ 0x08b1e802,
+ 0x08b1f00a,
+ 0x08b1f812,
+ 0x08b55802,
+ 0x08b5600a,
+ 0x08b56802,
+ 0x08b5701a,
+ 0x08b58052,
+ 0x08b5b00a,
+ 0x08b5b802,
+ 0x08b8e822,
+ 0x08b91032,
+ 0x08b9300a,
+ 0x08b93842,
+ 0x08c1602a,
+ 0x08c17882,
+ 0x08c1c00a,
+ 0x08c1c812,
+ 0x08c98002,
+ 0x08c9884a,
+ 0x08c9b81a,
+ 0x08c9d812,
+ 0x08c9e80a,
+ 0x08c9f002,
+ 0x08c9f808,
+ 0x08ca000a,
+ 0x08ca0808,
+ 0x08ca100a,
+ 0x08ca1802,
+ 0x08ce882a,
+ 0x08cea032,
+ 0x08ced012,
+ 0x08cee03a,
+ 0x08cf0002,
+ 0x08cf200a,
+ 0x08d00892,
+ 0x08d19852,
+ 0x08d1c80a,
+ 0x08d1d008,
+ 0x08d1d832,
+ 0x08d23802,
+ 0x08d28852,
+ 0x08d2b81a,
+ 0x08d2c822,
+ 0x08d42058,
+ 0x08d450c2,
+ 0x08d4b80a,
+ 0x08d4c012,
+ 0x08e1780a,
+ 0x08e18062,
+ 0x08e1c052,
+ 0x08e1f00a,
+ 0x08e1f802,
+ 0x08e49152,
+ 0x08e5480a,
+ 0x08e55062,
+ 0x08e5880a,
+ 0x08e59012,
+ 0x08e5a00a,
+ 0x08e5a812,
+ 0x08e98852,
+ 0x08e9d002,
+ 0x08e9e012,
+ 0x08e9f862,
+ 0x08ea3008,
+ 0x08ea3802,
+ 0x08ec504a,
+ 0x08ec8012,
+ 0x08ec981a,
+ 0x08eca802,
+ 0x08ecb00a,
+ 0x08ecb802,
+ 0x08f79812,
+ 0x08f7a81a,
+ 0x08f80012,
+ 0x08f81008,
+ 0x08f8180a,
+ 0x08f9a01a,
+ 0x08f9b042,
+ 0x08f9f01a,
+ 0x08fa0002,
+ 0x08fa080a,
+ 0x08fa1002,
+ 0x09a180f1,
+ 0x09a20002,
+ 0x09a238e2,
+ 0x0b578042,
+ 0x0b598062,
+ 0x0b7a7802,
+ 0x0b7a8b6a,
+ 0x0b7c7832,
+ 0x0b7f2002,
+ 0x0b7f801a,
+ 0x0de4e812,
+ 0x0de50031,
+ 0x0e7802d2,
+ 0x0e798162,
+ 0x0e8b2802,
+ 0x0e8b300a,
+ 0x0e8b3822,
+ 0x0e8b680a,
+ 0x0e8b7042,
+ 0x0e8b9871,
+ 0x0e8bd872,
+ 0x0e8c2862,
+ 0x0e8d5032,
+ 0x0e921022,
+ 0x0ed00362,
+ 0x0ed1db12,
+ 0x0ed3a802,
+ 0x0ed42002,
+ 0x0ed4d842,
+ 0x0ed508e2,
+ 0x0f000062,
+ 0x0f004102,
+ 0x0f00d862,
+ 0x0f011812,
+ 0x0f013042,
+ 0x0f047802,
+ 0x0f098062,
+ 0x0f157002,
+ 0x0f176032,
+ 0x0f276032,
+ 0x0f468062,
+ 0x0f4a2062,
+ 0x0f8007f3,
+ 0x0f8407f3,
+ 0x0f886823,
+ 0x0f897803,
+ 0x0f8b6053,
+ 0x0f8bf013,
+ 0x0f8c7003,
+ 0x0f8c8893,
+ 0x0f8d6b83,
+ 0x0f8f3199,
+ 0x0f9008e3,
+ 0x0f90d003,
+ 0x0f917803,
+ 0x0f919083,
+ 0x0f91e033,
+ 0x0f924ff3,
+ 0x0f964ff3,
+ 0x0f9a4ff3,
+ 0x0f9e4b13,
+ 0x0f9fd842,
+ 0x0fa007f3,
+ 0x0fa407f3,
+ 0x0fa803d3,
+ 0x0faa37f3,
+ 0x0fae37f3,
+ 0x0fb23093,
+ 0x0fb407f3,
+ 0x0fbba0b3,
+ 0x0fbeaaa3,
+ 0x0fc06033,
+ 0x0fc24073,
+ 0x0fc2d053,
+ 0x0fc44073,
+ 0x0fc57513,
+ 0x0fc862e3,
+ 0x0fc9e093,
+ 0x0fca3ff3,
+ 0x0fce3ff3,
+ 0x0fd23ff3,
+ 0x0fd63b83,
+ 0x0fe007f3,
+ 0x0fe407f3,
+ 0x0fe807f3,
+ 0x0fec07f3,
+ 0x0ff007f3,
+ 0x0ff407f3,
+ 0x0ff807f3,
+ 0x0ffc07d3,
+ 0x700001f1,
+ 0x700105f2,
+ 0x700407f1,
+ 0x700807f2,
+ 0x700c06f2,
+ 0x700f87f1,
+ 0x701387f1,
+ 0x701787f1,
+ 0x701b87f1,
+ 0x701f87f1,
+ 0x702387f1,
+ 0x702787f1,
+ 0x702b87f1,
+ 0x702f87f1,
+ 0x703387f1,
+ 0x703787f1,
+ 0x703b87f1,
+ 0x703f87f1,
+ 0x704387f1,
+ 0x704787f1,
+ 0x704b87f1,
+ 0x704f87f1,
+ 0x705387f1,
+ 0x705787f1,
+ 0x705b87f1,
+ 0x705f87f1,
+ 0x706387f1,
+ 0x706787f1,
+ 0x706b87f1,
+ 0x706f87f1,
+ 0x707387f1,
+ 0x707787f1,
+ 0x707b87f1,
+ 0x707f80f1};
/// Returns the extended grapheme cluster bondary property of a code point.
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
- // TODO FMT use std::ranges::upper_bound.
-
// The algorithm searches for the upper bound of the range and, when found,
// steps back one entry. This algorithm is used since the code point can be
// anywhere in the range. After a lower bound is found the next step is to
@@ -311,7 +1640,7 @@ inline constexpr uint32_t __entries[1480] = {
// size. Then the upper bound for code point 3 will return the entry after
// 0x1810. After moving to the previous entry the algorithm arrives at the
// correct entry.
- ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
+ ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
if (__i == 0)
return __property::__none;
diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h
index 4f93024b7c69..771a03ff2fa9 100644
--- a/libcxx/include/__format/format_arg.h
+++ b/libcxx/include/__format/format_arg.h
@@ -45,16 +45,22 @@ namespace __format {
/// It could be packed in 4-bits but that means a new type directly becomes an
/// ABI break. The packed type is 64-bit so this reduces the maximum number of
/// packed elements from 16 to 12.
+///
+/// @note Some members of this enum are an extension. These extensions need
+/// special behaviour in visit_format_arg. There they need to be wrapped in a
+/// handle to satisfy the user observable behaviour. The internal function
+/// __visit_format_arg doesn't do this wrapping. So in the format functions
+/// this function is used to avoid unneeded overhead.
enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
__none,
__boolean,
__char_type,
__int,
__long_long,
- __i128,
+ __i128, // extension
__unsigned,
__unsigned_long_long,
- __u128,
+ __u128, // extension
__float,
__double,
__long_double,
@@ -85,9 +91,11 @@ constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
} // namespace __format
+// This function is not user obervable, so it can directly use the non-standard
+// types of the "variant". See __arg_t for more details.
template <class _Visitor, class _Context>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis,
- basic_format_arg<_Context> __arg) {
+_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), __arg.__value_.__monostate_);
@@ -153,7 +161,7 @@ public:
using _Dp = remove_cvref_t<_Tp>;
using _Formatter = typename _Context::template formatter_type<_Dp>;
constexpr bool __const_formattable =
- requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };
+ requires { _Formatter().format(std::declval<const _Dp&>(), std::declval<_Context&>()); };
using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
@@ -265,6 +273,28 @@ private:
typename __basic_format_arg_value<_Context>::__handle& __handle_;
};
+// This function is user facing, so it must wrap the non-standard types of
+// the "variant" in a handle to stay conforming. See __arg_t for more details.
+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_) {
+# ifndef _LIBCPP_HAS_NO_INT128
+ case __format::__arg_t::__i128: {
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
+ }
+
+ case __format::__arg_t::__u128: {
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
+ }
+# endif
+ default:
+ return _VSTD::__visit_format_arg(_VSTD::forward<_Visitor>(__vis), __arg);
+ }
+}
+
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__format/format_arg_store.h b/libcxx/include/__format/format_arg_store.h
index 26a5e71b93af..6f4f4c3617ad 100644
--- a/libcxx/include/__format/format_arg_store.h
+++ b/libcxx/include/__format/format_arg_store.h
@@ -19,6 +19,7 @@
#include <__config>
#include <__format/concepts.h>
#include <__format/format_arg.h>
+#include <__utility/forward.h>
#include <cstring>
#include <string>
#include <string_view>
@@ -197,7 +198,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
int __shift = 0;
(
[&] {
- basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args);
+ basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args);
if (__shift != 0)
__types |= static_cast<uint64_t>(__arg.__type_) << __shift;
else
@@ -211,7 +212,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
template <class _Context, class... _Args>
_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {
- ([&] { *__data++ = __create_format_arg<_Context>(__args); }(), ...);
+ ([&] { *__data++ = __format::__create_format_arg<_Context>(__args); }(), ...);
}
template <class _Context, size_t N>
diff --git a/libcxx/include/__format/format_args.h b/libcxx/include/__format/format_args.h
index d90dc50acbd1..8b8fbde92fe6 100644
--- a/libcxx/include/__format/format_args.h
+++ b/libcxx/include/__format/format_args.h
@@ -71,6 +71,7 @@ private:
const basic_format_arg<_Context>* __args_;
};
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_args);
#endif //_LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index b9a41db05d51..85e00eb222cf 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -11,14 +11,19 @@
#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
#include <__availability>
+#include <__concepts/same_as.h>
#include <__config>
#include <__format/buffer.h>
+#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
#include <__format/format_args.h>
+#include <__format/format_error.h>
#include <__format/format_fwd.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
+#include <__memory/addressof.h>
#include <__utility/move.h>
-#include <concepts>
+#include <__variant/monostate.h>
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
@@ -50,8 +55,7 @@ __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));
+ return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, _VSTD::move(__loc));
}
#else
template <class _OutIt, class _CharT>
@@ -87,9 +91,6 @@ public:
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);
@@ -101,8 +102,8 @@ public:
return *__loc_;
}
#endif
- _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; }
- _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; }
+ _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
+ _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
private:
iterator __out_it_;
@@ -144,6 +145,77 @@ private:
#endif
};
+// A specialization for __retarget_buffer
+//
+// See __retarget_buffer for the motivation for this specialization.
+//
+// This context holds a reference to the instance of the basic_format_context
+// that is retargeted. It converts a formatting argument when it is requested
+// during formatting. It is expected that the usage of the arguments is rare so
+// the lookups are not expected to be used often. An alternative would be to
+// convert all elements during construction.
+//
+// The elements of the retargets context are only used when an underlying
+// formatter uses a locale specific formatting or an formatting argument is
+// part for the format spec. For example
+// format("{:256:{}}", input, 8);
+// Here the width of an element in input is determined dynamically.
+// Note when the top-level element has no width the retargeting is not needed.
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
+ basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> {
+public:
+ using iterator = typename __format::__retarget_buffer<_CharT>::__iterator;
+ using char_type = _CharT;
+ template <class _Tp>
+ using formatter_type = formatter<_Tp, _CharT>;
+
+ template <class _Context>
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(iterator __out_it, _Context& __ctx)
+ : __out_it_(std::move(__out_it)),
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ __loc_([](void* __c) { return static_cast<_Context*>(__c)->locale(); }),
+# endif
+ __ctx_(std::addressof(__ctx)),
+ __arg_([](void* __c, size_t __id) {
+ return std::visit_format_arg(
+ [&](auto __arg) -> basic_format_arg<basic_format_context> {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ return {};
+ else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
+ // At the moment it's not possible for formatting to use a re-targeted handle.
+ // TODO FMT add this when support is needed.
+ std::__throw_format_error("Re-targeting handle not supported");
+ else
+ return basic_format_arg<basic_format_context>{
+ __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
+ __basic_format_arg_value<basic_format_context>(__arg)};
+ },
+ static_cast<_Context*>(__c)->arg(__id));
+ }) {
+ }
+
+ _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
+ return __arg_(__ctx_, __id);
+ }
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() { return __loc_(__ctx_); }
+# endif
+ _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
+ _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
+
+private:
+ iterator __out_it_;
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ std::locale (*__loc_)(void* __ctx);
+# endif
+
+ void* __ctx_;
+ basic_format_arg<basic_format_context> (*__arg_)(void* __ctx, size_t __id);
+};
+
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context);
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h
index 67ff41cbc3d8..002d1a40a226 100644
--- a/libcxx/include/__format/format_error.h
+++ b/libcxx/include/__format/format_error.h
@@ -11,11 +11,8 @@
#define _LIBCPP___FORMAT_FORMAT_ERROR_H
#include <__config>
-#include <stdexcept>
-
-#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
-#endif
+#include <stdexcept>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -31,7 +28,14 @@ public:
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
: runtime_error(__s) {}
- virtual ~format_error() noexcept;
+ // TODO FMT Remove when format is no longer experimental.
+ // Avoids linker errors when building the Clang-cl Windows DLL which doesn't
+ // support the experimental library.
+# ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
+ ~format_error() noexcept override;
+# else
+ ~format_error() noexcept override {}
+# endif
};
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
new file mode 100644
index 000000000000..185148ccba53
--- /dev/null
+++ b/libcxx/include/__format/format_functions.h
@@ -0,0 +1,661 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_FUNCTIONS
+#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS
+
+// TODO FMT This is added to fix Apple back-deployment.
+#include <version>
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#include <__algorithm/clamp.h>
+#include <__availability>
+#include <__concepts/convertible_to.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__debug>
+#include <__format/buffer.h>
+#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.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 <__iterator/back_insert_iterator.h>
+#include <__iterator/incrementable_traits.h>
+#include <__variant/monostate.h>
+#include <array>
+#include <string>
+#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 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 = format_context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
+}
+#endif
+
+namespace __format {
+
+/// Helper class parse and handle argument.
+///
+/// When parsing a handle which is not enabled the code is ill-formed.
+/// This helper uses the parser of the appropriate formatter for the stored type.
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
+ __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
+ formatter<_Tp, _CharT> __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ };
+ }
+
+ // Before calling __parse the proper handler needs to be set with __enable.
+ // The default handler isn't a core constant expression.
+ _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
+ : __parse_([](basic_format_parse_context<_CharT>&) { std::__throw_format_error("Not a handle"); }) {}
+
+private:
+ void (*__parse_)(basic_format_parse_context<_CharT>&);
+};
+
+// Dummy format_context only providing the parts used during constant
+// validation of the basic_format_string.
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
+public:
+ using char_type = _CharT;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
+ const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
+ : __args_(__args), __handles_(__handles), __size_(__size) {}
+
+ // During the compile-time validation nothing needs to be written.
+ // Therefore all operations of this iterator are a NOP.
+ struct iterator {
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
+ };
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
+ if (__id >= __size_)
+ std::__throw_format_error("Argument index out of bounds");
+ return __args_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
+ if (__id >= __size_)
+ std::__throw_format_error("Argument index out of bounds");
+ return __handles_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
+ _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
+
+private:
+ const __arg_t* __args_;
+ const __compile_time_handle<_CharT>* __handles_;
+ size_t __size_;
+};
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __compile_time_validate_integral(__arg_t __type) {
+ switch (__type) {
+ case __arg_t::__int:
+ case __arg_t::__long_long:
+ case __arg_t::__i128:
+ case __arg_t::__unsigned:
+ case __arg_t::__unsigned_long_long:
+ case __arg_t::__u128:
+ return;
+
+ default:
+ std::__throw_format_error("Argument isn't an integral type");
+ }
+}
+
+// _HasPrecision does the formatter have a precision?
+template <class _CharT, class _Tp, bool _HasPrecision = false>
+_LIBCPP_HIDE_FROM_ABI constexpr void
+__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx) {
+ formatter<_Tp, _CharT> __formatter;
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ // [format.string.std]/7
+ // ... If the corresponding formatting argument is not of integral type, or
+ // its value is negative for precision or non-positive for width, an
+ // exception of type format_error is thrown.
+ //
+ // Validate whether the arguments are integrals.
+ if (__formatter.__parser_.__width_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
+
+ if constexpr (_HasPrecision)
+ if (__formatter.__parser_.__precision_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
+}
+
+// This function is not user facing, so it can directly use the non-standard types of the "variant".
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx,
+ __arg_t __type) {
+ switch (__type) {
+ case __arg_t::__none:
+ std::__throw_format_error("Invalid argument");
+ case __arg_t::__boolean:
+ return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
+ case __arg_t::__char_type:
+ return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
+ case __arg_t::__int:
+ return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
+ case __arg_t::__long_long:
+ return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
+ case __arg_t::__i128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
+# else
+ std::__throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__unsigned:
+ return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
+ case __arg_t::__unsigned_long_long:
+ return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
+ case __arg_t::__u128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
+# else
+ std::__throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__float:
+ return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
+ case __arg_t::__double:
+ return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
+ case __arg_t::__long_double:
+ return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
+ case __arg_t::__const_char_type_ptr:
+ return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
+ case __arg_t::__string_view:
+ return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
+ case __arg_t::__ptr:
+ return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
+ case __arg_t::__handle:
+ std::__throw_format_error("Handle should use __compile_time_validate_handle_argument");
+ }
+ std::__throw_format_error("Invalid argument");
+}
+
+template <class _CharT, class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI constexpr 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);
+
+ bool __parse = *__r.__ptr == _CharT(':');
+ 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:
+ std::__throw_format_error("The replacement field arg-id should terminate at a ':' or '}'");
+ }
+
+ if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
+ __arg_t __type = __ctx.arg(__r.__value);
+ if (__type == __arg_t::__handle)
+ __ctx.__handle(__r.__value).__parse(__parse_ctx);
+ else
+ __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
+ } else
+ _VSTD::__visit_format_arg(
+ [&](auto __arg) {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ std::__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;
+ if (__parse)
+ __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('}'))
+ std::__throw_format_error("The replacement field misses a terminating '}'");
+
+ return ++__begin;
+}
+
+template <class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI constexpr 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)
+ std::__throw_format_error("The format string terminates at a '{'");
+
+ if (*__begin != _CharT('{')) [[likely]] {
+ __ctx.advance_to(_VSTD::move(__out_it));
+ __begin =
+ __format::__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('}'))
+ std::__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 _CharT, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS basic_format_string {
+ template <class _Tp>
+ requires convertible_to<const _Tp&, basic_string_view<_CharT>>
+ consteval basic_format_string(const _Tp& __str) : __str_{__str} {
+ __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
+ _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept {
+ return __str_;
+ }
+
+private:
+ basic_string_view<_CharT> __str_;
+
+ using _Context = __format::__compile_time_basic_format_context<_CharT>;
+
+ static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
+ __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
+
+ // TODO FMT remove this work-around when the AIX ICE has been resolved.
+# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
+ template <class _Tp>
+ static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }
+
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
+ __get_handle<_Args>()...};
+# else
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
+ using _Tp = remove_cvref_t<_Args>;
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }()...};
+# endif
+};
+
+template <class... _Args>
+using format_string = basic_format_string<char, type_identity_t<_Args>...>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
+#endif
+
+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 {
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__out_it();
+ }
+}
+
+// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
+// https://reviews.llvm.org/D110499#inline-1180704
+// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
+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, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
+ _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, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
+ _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(format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(__fmt.get(), _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(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...));
+}
+
+#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, wformat_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
+}
+#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 {
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__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, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
+ _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, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
+ _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,
+ format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
+ _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, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ locale __loc, basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _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, format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
+ _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 format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
+}
+#endif
+
+#endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#endif // _LIBCPP___FORMAT_FORMAT_FUNCTIONS
diff --git a/libcxx/include/__format/format_parse_context.h b/libcxx/include/__format/format_parse_context.h
index 272b615d1048..30e3a7dfdaf3 100644
--- a/libcxx/include/__format/format_parse_context.h
+++ b/libcxx/include/__format/format_parse_context.h
@@ -54,8 +54,7 @@ public:
_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");
+ std::__throw_format_error("Using automatic argument numbering in manual argument numbering mode");
if (__indexing_ == __unknown)
__indexing_ = __automatic;
@@ -63,8 +62,7 @@ public:
}
_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");
+ std::__throw_format_error("Using manual argument numbering in automatic argument numbering mode");
if (__indexing_ == __unknown)
__indexing_ = __manual;
@@ -77,7 +75,7 @@ public:
// 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");
+ std::__throw_format_error("Argument index outside the valid range");
}
private:
@@ -88,6 +86,7 @@ private:
size_t __next_arg_id_;
size_t __num_args_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);
using format_parse_context = basic_format_parse_context<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
diff --git a/libcxx/include/__format/format_string.h b/libcxx/include/__format/format_string.h
index 51c3c7a1a6d8..d9caf866a17d 100644
--- a/libcxx/include/__format/format_string.h
+++ b/libcxx/include/__format/format_string.h
@@ -33,6 +33,9 @@ struct _LIBCPP_TEMPLATE_VIS __parse_number_result {
};
template <class _CharT>
+__parse_number_result(const _CharT*, uint32_t) -> __parse_number_result<_CharT>;
+
+template <class _CharT>
_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
__parse_number(const _CharT* __begin, const _CharT* __end);
@@ -70,7 +73,7 @@ __parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
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_number_result<_CharT> __r = __format::__parse_number(__begin, __end);
__parse_ctx.check_arg_id(__r.__value);
return __r;
}
@@ -117,7 +120,7 @@ __parse_number(const _CharT* __begin, const _CharT* __end_input) {
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");
+ std::__throw_format_error("The numeric value of the format-spec is too large");
__value = __v;
}
@@ -146,8 +149,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
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");
+ std::__throw_format_error("The arg-id of the format-spec starts with an invalid character");
return __detail::__parse_manual(__begin, __end, __parse_ctx);
}
diff --git a/libcxx/include/__format/format_to_n_result.h b/libcxx/include/__format/format_to_n_result.h
index 25caa1c9e98d..f1ed9a0982ab 100644
--- a/libcxx/include/__format/format_to_n_result.h
+++ b/libcxx/include/__format/format_to_n_result.h
@@ -26,6 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
_OutIt out;
iter_difference_t<_OutIt> size;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);
#endif //_LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__format/formatter.h b/libcxx/include/__format/formatter.h
index 4816f961c445..900a09af4e99 100644
--- a/libcxx/include/__format/formatter.h
+++ b/libcxx/include/__format/formatter.h
@@ -11,7 +11,6 @@
#define _LIBCPP___FORMAT_FORMATTER_H
#include <__availability>
-#include <__concepts/same_as.h>
#include <__config>
#include <__format/format_fwd.h>
@@ -39,15 +38,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
formatter& operator=(const formatter&) = delete;
};
-namespace __formatter {
+# if _LIBCPP_STD_VER > 20
-/** The character types that formatters are specialized for. */
-template <class _CharT>
-concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {
+ if constexpr (requires { __formatter.set_debug_format(); })
+ __formatter.set_debug_format();
+}
-} // namespace __formatter
-
-#endif //_LIBCPP_STD_VER > 17
+# endif // _LIBCPP_STD_VER > 20
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__format/formatter_bool.h b/libcxx/include/__format/formatter_bool.h
index cdb0631f87d4..0d005a1bee23 100644
--- a/libcxx/include/__format/formatter_bool.h
+++ b/libcxx/include/__format/formatter_bool.h
@@ -14,8 +14,8 @@
#include <__availability>
#include <__config>
#include <__debug>
+#include <__format/concepts.h>
#include <__format/format_error.h>
-#include <__format/format_fwd.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
public:
_LIBCPP_HIDE_FROM_ABI constexpr auto
diff --git a/libcxx/include/__format/formatter_char.h b/libcxx/include/__format/formatter_char.h
index a3ca36ec0a62..8a92e7445b49 100644
--- a/libcxx/include/__format/formatter_char.h
+++ b/libcxx/include/__format/formatter_char.h
@@ -13,7 +13,7 @@
#include <__availability>
#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_fwd.h>
+#include <__format/concepts.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
public:
_LIBCPP_HIDE_FROM_ABI constexpr auto
@@ -44,6 +44,11 @@ public:
if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+# if _LIBCPP_STD_VER > 20
+ if (__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+# endif
+
if constexpr (sizeof(_CharT) <= sizeof(int))
// Promotes _CharT to an integral type. This reduces the number of
// instantiations of __format_integer reducing code size.
@@ -61,6 +66,10 @@ public:
return format(static_cast<wchar_t>(__value), __ctx);
}
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
+# endif
+
__format_spec::__parser<_CharT> __parser_;
};
diff --git a/libcxx/include/__format/formatter_floating_point.h b/libcxx/include/__format/formatter_floating_point.h
index 90a76193196e..a544b53f7e6d 100644
--- a/libcxx/include/__format/formatter_floating_point.h
+++ b/libcxx/include/__format/formatter_floating_point.h
@@ -10,17 +10,16 @@
#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/max.h>
#include <__algorithm/min.h>
#include <__algorithm/rotate.h>
#include <__algorithm/transform.h>
#include <__concepts/arithmetic.h>
#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_fwd.h>
+#include <__format/concepts.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
@@ -103,7 +102,7 @@ template <class _Tp>
struct __traits;
template <floating_point _Fp>
-static constexpr size_t __float_buffer_size(int __precision) {
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __float_buffer_size(int __precision) {
using _Traits = __traits<_Fp>;
return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;
}
@@ -183,6 +182,7 @@ public:
_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; }
+ _LIBCPP_HIDE_FROM_ABI void __add_trailing_zeros(int __zeros) { __num_trailing_zeros_ += __zeros; }
private:
int __precision_;
@@ -216,7 +216,7 @@ struct __float_result {
/// \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) {
+ if (__size >= 4) {
__first = __last - _VSTD::min(__size, ptrdiff_t(6));
for (; __first != __last - 3; ++__first) {
if (*__first == 'e')
@@ -404,6 +404,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
// 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, '.');
}
}
@@ -454,7 +455,10 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
switch (__type) {
case __format_spec::__type::__default:
- return __formatter::__format_buffer_default(__buffer, __value, __first);
+ if (__has_precision)
+ return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+ else
+ return __formatter::__format_buffer_default(__buffer, __value, __first);
case __format_spec::__type::__hexfloat_lower_case:
return __formatter::__format_buffer_hexadecimal_lower_case(
@@ -494,7 +498,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
const __float_result& __result,
_VSTD::locale __loc,
__format_spec::__parsed_specifications<_CharT> __specs) {
- const auto& __np = use_facet<numpunct<_CharT>>(__loc);
+ const auto& __np = std::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.
@@ -528,13 +532,13 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
// 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_, __specs.__fill_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__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));
+ __out_it = __formatter::__copy(__first, __digits, _VSTD::move(__out_it));
} else {
auto __r = __grouping.rbegin();
auto __e = __grouping.rend() - 1;
@@ -546,7 +550,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
// 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));
+ __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
__first += *__r;
if (__r == __e)
@@ -560,16 +564,16 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
// 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'));
+ __out_it = __formatter::__copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));
+ __out_it = __formatter::__fill(_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));
+ __out_it = __formatter::__copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
// alignment
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
}
# endif // _LIBCPP_HAS_NO_LOCALIZATION
@@ -625,20 +629,51 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
__float_result __result = __formatter::__format_buffer(
__buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
- if (__specs.__std_.__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;
+ if (__specs.__std_.__alternate_form_) {
+ if (__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;
+ }
- // 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;
+ // [format.string.std]/6
+ // In addition, for g and G conversions, trailing zeros are not removed
+ // from the result.
+ //
+ // If the type option for a floating-point type is none it may use the
+ // general formatting, but it's not a g or G conversion. So in that case
+ // the formatting should not append trailing zeros.
+ bool __is_general = __specs.__std_.__type_ == __format_spec::__type::__general_lower_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
+
+ if (__is_general) {
+ // https://en.cppreference.com/w/c/io/fprintf
+ // Let P equal the precision if nonzero, 6 if the precision is not
+ // specified, or 1 if the precision is 0. Then, if a conversion with
+ // style E would have an exponent of X:
+ int __p = _VSTD::max(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
+ if (__result.__exponent == __result.__last)
+ // if P > X >= -4, the conversion is with style f or F and precision P - 1 - X.
+ // By including the radix point it calculates P - (1 + X)
+ __p -= __result.__radix_point - __buffer.begin();
+ else
+ // otherwise, the conversion is with style e or E and precision P - 1.
+ --__p;
+
+ ptrdiff_t __precision = (__result.__exponent - __result.__radix_point) - 1;
+ if (__precision < __p)
+ __buffer.__add_trailing_zeros(__p - __precision);
+ }
}
# ifndef _LIBCPP_HAS_NO_LOCALIZATION
@@ -651,14 +686,15 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
if (__size + __num_trailing_zeros >= __specs.__width_) {
if (__num_trailing_zeros && __result.__exponent != __result.__last)
// Insert trailing zeros before exponent character.
- return _VSTD::copy(
+ return __formatter::__copy(
__result.__exponent,
__result.__last,
- _VSTD::fill_n(
- _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0')));
+ __formatter::__fill(__formatter::__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'));
+ return __formatter::__fill(
+ __formatter::__copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
}
auto __out_it = __ctx.out();
@@ -684,7 +720,7 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
} // namespace __formatter
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
public:
_LIBCPP_HIDE_FROM_ABI constexpr auto
@@ -702,13 +738,13 @@ public:
__format_spec::__parser<_CharT> __parser_;
};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
: public __formatter_floating_point<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
: public __formatter_floating_point<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
: public __formatter_floating_point<_CharT> {};
diff --git a/libcxx/include/__format/formatter_integer.h b/libcxx/include/__format/formatter_integer.h
index 3139c9efdf80..b4be9f9a07ce 100644
--- a/libcxx/include/__format/formatter_integer.h
+++ b/libcxx/include/__format/formatter_integer.h
@@ -13,7 +13,7 @@
#include <__availability>
#include <__concepts/arithmetic.h>
#include <__config>
-#include <__format/format_fwd.h>
+#include <__format/concepts.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
@@ -30,7 +30,7 @@
#if _LIBCPP_STD_VER > 17
- template <__formatter::__char_type _CharT>
+ template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
public:
@@ -59,43 +59,43 @@ public:
};
// Signed integral types.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
: public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
: public __formatter_integer<_CharT> {};
# ifndef _LIBCPP_HAS_NO_INT128
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
: public __formatter_integer<_CharT> {};
# endif
// Unsigned integral types.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
: public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
: public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
: public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
: public __formatter_integer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
: public __formatter_integer<_CharT> {};
# ifndef _LIBCPP_HAS_NO_INT128
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
: public __formatter_integer<_CharT> {};
# endif
diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h
index b9ed5fe80f7f..fe3a06311be2 100644
--- a/libcxx/include/__format/formatter_integral.h
+++ b/libcxx/include/__format/formatter_integral.h
@@ -13,11 +13,12 @@
#include <__concepts/arithmetic.h>
#include <__concepts/same_as.h>
#include <__config>
+#include <__format/concepts.h>
#include <__format/format_error.h>
-#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
#include <__utility/unreachable.h>
+#include <array>
#include <charconv>
#include <limits>
#include <string>
@@ -112,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const
// Char
//
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
_LIBCPP_HIDE_FROM_ABI auto __format_char(
integral auto __value,
output_iterator<const _CharT&> auto __out_it,
@@ -216,7 +217,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
# ifndef _LIBCPP_HAS_NO_LOCALIZATION
if (__specs.__std_.__locale_specific_form_) {
- const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ const auto& __np = std::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
@@ -243,7 +244,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
// 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));
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
__specs.__alignment_ = __format_spec::__alignment::__right;
__specs.__fill_ = _CharT('0');
int32_t __size = __first - __begin;
@@ -309,7 +310,7 @@ __format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specification
auto __r = std::__to_unsigned_like(__value);
bool __negative = __value < 0;
if (__negative)
- __r = __complement(__r);
+ __r = std::__complement(__r);
return __formatter::__format_integer(__r, __ctx, __specs, __negative);
}
@@ -341,7 +342,7 @@ __format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<
-> decltype(__ctx.out()) {
# ifndef _LIBCPP_HAS_NO_LOCALIZATION
if (__specs.__std_.__locale_specific_form_) {
- const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
+ const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
}
diff --git a/libcxx/include/__format/formatter_output.h b/libcxx/include/__format/formatter_output.h
index e09534c41dff..467692559ce9 100644
--- a/libcxx/include/__format/formatter_output.h
+++ b/libcxx/include/__format/formatter_output.h
@@ -10,16 +10,23 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
-#include <__algorithm/copy.h>
-#include <__algorithm/copy_n.h>
-#include <__algorithm/fill_n.h>
-#include <__algorithm/transform.h>
+#include <__algorithm/ranges_copy.h>
+#include <__algorithm/ranges_fill_n.h>
+#include <__algorithm/ranges_transform.h>
+#include <__chrono/statically_widen.h>
+#include <__concepts/same_as.h>
#include <__config>
+#include <__format/buffer.h>
+#include <__format/concepts.h>
+#include <__format/escaped_output_table.h>
#include <__format/formatter.h>
#include <__format/parser_std_format_spec.h>
#include <__format/unicode.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__type_traits/make_unsigned.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
+#include <charconv>
#include <cstddef>
#include <string>
#include <string_view>
@@ -86,6 +93,74 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align
__libcpp_unreachable();
}
+/// Copy wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
+ __out_it.__get_container()->__copy(__str);
+ return __out_it;
+ } else if constexpr (_VSTD::same_as<decltype(__out_it),
+ typename __format::__retarget_buffer<_OutCharT>::__iterator>) {
+ __out_it.__buffer_->__copy(__str);
+ return __out_it;
+ } else {
+ return std::ranges::copy(__str, _VSTD::move(__out_it)).out;
+ }
+}
+
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__copy(const _CharT* __first, const _CharT* __last, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ return __formatter::__copy(basic_string_view{__first, __last}, _VSTD::move(__out_it));
+}
+
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __copy(const _CharT* __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ return __formatter::__copy(basic_string_view{__first, __n}, _VSTD::move(__out_it));
+}
+
+/// Transform wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT, class _UnaryOperation>
+_LIBCPP_HIDE_FROM_ABI auto
+__transform(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _OutCharT&> auto __out_it,
+ _UnaryOperation __operation) -> decltype(__out_it) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
+ __out_it.__get_container()->__transform(__first, __last, _VSTD::move(__operation));
+ return __out_it;
+ } else if constexpr (_VSTD::same_as<decltype(__out_it),
+ typename __format::__retarget_buffer<_OutCharT>::__iterator>) {
+ __out_it.__buffer_->__transform(__first, __last, _VSTD::move(__operation));
+ return __out_it;
+ } else {
+ return std::ranges::transform(__first, __last, _VSTD::move(__out_it), __operation).out;
+ }
+}
+
+/// Fill wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
+_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_CharT>>>) {
+ __out_it.__get_container()->__fill(__n, __value);
+ return __out_it;
+ } else if constexpr (_VSTD::same_as<decltype(__out_it), typename __format::__retarget_buffer<_CharT>::__iterator>) {
+ __out_it.__buffer_->__fill(__n, __value);
+ return __out_it;
+ } else {
+ return std::ranges::fill_n(_VSTD::move(__out_it), __n, __value);
+ }
+}
+
template <class _OutIt, class _CharT>
_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
const char* __last, string&& __grouping, _CharT __sep,
@@ -97,22 +172,22 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
__padding_size_result __padding = {0, 0};
if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
// Write [sign][prefix].
- __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
if (__specs.__width_ > __size) {
// Write zero padding.
__padding.__before_ = __specs.__width_ - __size;
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
}
} else {
if (__specs.__width_ > __size) {
// Determine padding and write padding.
- __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
+ __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
}
// Write [sign][prefix].
- __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
}
auto __r = __grouping.rbegin();
@@ -133,10 +208,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
while (true) {
if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
__last = __first + *__r;
- __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
+ __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
__first = __last;
} else {
- __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
+ __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
__first += *__r;
}
@@ -147,7 +222,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
*__out_it++ = __sep;
}
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
}
/// Writes the input to the output with the required padding.
@@ -155,12 +230,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
/// Since the output column width is specified the function can be used for
/// ASCII and Unicode output.
///
-/// \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 __first Pointer to the first element to write.
-/// \param __last Pointer beyond the last element to write.
+/// \param __str The string to write.
/// \param __out_it The output iterator to write to.
/// \param __specs The parsed formatting specifications.
/// \param __size The (estimated) output column width. When the elements
@@ -174,31 +247,42 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
/// conversion, which means the [\a __first, \a __last) always contains elements
/// of the type \c char.
template <class _CharT, class _ParserCharT>
-_LIBCPP_HIDE_FROM_ABI auto __write(
- const _CharT* __first,
- const _CharT* __last,
- output_iterator<const _CharT&> auto __out_it,
- __format_spec::__parsed_specifications<_ParserCharT> __specs,
- ptrdiff_t __size) -> decltype(__out_it) {
- _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
-
+_LIBCPP_HIDE_FROM_ABI auto
+__write(basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ ptrdiff_t __size) -> decltype(__out_it) {
if (__size >= __specs.__width_)
- return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
+ return __formatter::__copy(__str, _VSTD::move(__out_it));
__padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
- __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__copy(__str, _VSTD::move(__out_it));
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ ptrdiff_t __size) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ return __formatter::__write(basic_string_view{__first, __last}, _VSTD::move(__out_it), __specs, __size);
}
/// \overload
///
/// Calls the function above where \a __size = \a __last - \a __first.
template <class _CharT, class _ParserCharT>
-_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last,
- output_iterator<const _CharT&> auto __out_it,
- __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
- return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
+_LIBCPP_HIDE_FROM_ABI auto
+__write(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ return __formatter::__write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
}
template <class _CharT, class _ParserCharT, class _UnaryOperation>
@@ -210,12 +294,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _Cha
ptrdiff_t __size = __last - __first;
if (__size >= __specs.__width_)
- return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
+ return __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
- __padding_size_result __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
- __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
- return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+ __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
}
/// Writes additional zero's for the precision before the exponent.
@@ -239,12 +323,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
_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, __specs.__width_, __specs.__alignment_);
- __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__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_, __specs.__fill_);
+ __formatter::__padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__copy(__first, __exponent, _VSTD::move(__out_it));
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
+ __out_it = __formatter::__copy(__exponent, __last, _VSTD::move(__out_it));
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
}
/// Writes a string using format's width estimation algorithm.
@@ -262,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
// No padding -> copy the string
if (!__specs.__has_width())
- return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it));
+ return __formatter::__copy(__str, _VSTD::move(__out_it));
// Note when the estimated width is larger than size there's no padding. So
// there's no reason to get the real size when the estimate is larger than or
@@ -270,8 +354,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
size_t __size =
__format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
.__width_;
-
- return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+ return __formatter::__write(__str, _VSTD::move(__out_it), __specs, __size);
}
template <class _CharT>
@@ -296,9 +379,188 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string(
int __size = __formatter::__truncate(__str, __specs.__precision_);
- return __write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+ return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+}
+
+# if _LIBCPP_STD_VER > 20
+
+struct __nul_terminator {};
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __cstr, __nul_terminator) {
+ return *__cstr == _CharT('\0');
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void
+__write_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value, const _CharT* __prefix) {
+ back_insert_iterator __out_it{__str};
+ std::ranges::copy(__prefix, __nul_terminator{}, __out_it);
+
+ char __buffer[8];
+ to_chars_result __r = std::to_chars(std::begin(__buffer), std::end(__buffer), __value, 16);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ std::ranges::copy(std::begin(__buffer), __r.ptr, __out_it);
+
+ __str += _CharT('}');
+}
+
+// [format.string.escaped]/2.2.1.2
+// ...
+// then the sequence \u{hex-digit-sequence} is appended to E, where
+// hex-digit-sequence is the shortest hexadecimal representation of C using
+// lower-case hexadecimal digits.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __write_well_formed_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value) {
+ __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\u{"));
+}
+
+// [format.string.escaped]/2.2.3
+// Otherwise (X is a sequence of ill-formed code units), each code unit U is
+// appended to E in order as the sequence \x{hex-digit-sequence}, where
+// hex-digit-sequence is the shortest hexadecimal representation of U using
+// lower-case hexadecimal digits.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_CharT>& __str, char32_t __value) {
+ __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\x{"));
+}
+
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value) {
+# ifdef _LIBCPP_HAS_NO_UNICODE
+ // For ASCII assume everything above 127 is printable.
+ if (__value > 127)
+ return false;
+# endif
+
+ if (!__escaped_output_table::__needs_escape(__value))
+ return false;
+
+ __formatter::__write_well_formed_escaped_code_unit(__str, __value);
+ return true;
+}
+
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr char32_t __to_char32(_CharT __value) {
+ return static_cast<make_unsigned_t<_CharT>>(__value);
+}
+
+enum class _LIBCPP_ENUM_VIS __escape_quotation_mark { __apostrophe, __double_quote };
+
+// [format.string.escaped]/2
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
+__is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __escape_quotation_mark __mark) {
+ // 2.2.1.1 - Mapped character in [tab:format.escape.sequences]
+ switch (__value) {
+ case _CharT('\t'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\t");
+ return true;
+ case _CharT('\n'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\n");
+ return true;
+ case _CharT('\r'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\r");
+ return true;
+ case _CharT('\''):
+ if (__mark == __escape_quotation_mark::__apostrophe)
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\')");
+ else
+ __str += __value;
+ return true;
+ case _CharT('"'):
+ if (__mark == __escape_quotation_mark::__double_quote)
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\")");
+ else
+ __str += __value;
+ return true;
+ case _CharT('\\'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\\)");
+ return true;
+
+ // 2.2.1.2 - Space
+ case _CharT(' '):
+ __str += __value;
+ return true;
+ }
+
+ // 2.2.2
+ // Otherwise, if X is a shift sequence, the effect on E and further
+ // decoding of S is unspecified.
+ // For now shift sequences are ignored and treated as Unicode. Other parts
+ // of the format library do the same. It's unknown how ostream treats them.
+ // TODO FMT determine what to do with shift sequences.
+
+ // 2.2.1.2.1 and 2.2.1.2.2 - Escape
+ return __formatter::__is_escaped_sequence_written(__str, __formatter::__to_char32(__value));
}
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void
+__escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) {
+ __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()};
+
+ while (!__view.__at_end()) {
+ const _CharT* __first = __view.__position();
+ typename __unicode::__consume_p2286_result __result = __view.__consume_p2286();
+ if (__result.__ill_formed_size == 0) {
+ if (!__formatter::__is_escaped_sequence_written(__str, __result.__value, __mark))
+ // 2.2.1.3 - Add the character
+ ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str));
+
+ } else {
+ // 2.2.3 sequence of ill-formed code units
+ // The number of code-units in __result.__value depends on the character type being used.
+ if constexpr (sizeof(_CharT) == 1) {
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1 || __result.__ill_formed_size == 4,
+ "illegal number of invalid code units.");
+ if (__result.__ill_formed_size == 1) // ill-formed, one code unit
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xff);
+ else { // out of valid range, four code units
+ // The code point was properly encoded, decode the value.
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value >> 18 | 0xf0);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 12 & 0x3f) | 0x80);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 6 & 0x3f) | 0x80);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value & 0x3f) | 0x80);
+ }
+ } else if constexpr (sizeof(_CharT) == 2) {
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-16 at most one invalid code unit");
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xffff);
+ } else {
+ static_assert(sizeof(_CharT) == 4, "unsupported character width");
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-32 one code unit is one code point");
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value);
+ }
+ }
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_escaped_char(_CharT __value,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ basic_string<_CharT> __str;
+ __str += _CharT('\'');
+ __formatter::__escape(__str, basic_string_view{std::addressof(__value), 1}, __escape_quotation_mark::__apostrophe);
+ __str += _CharT('\'');
+ return __formatter::__write(__str.data(), __str.data() + __str.size(), _VSTD::move(__out_it), __specs, __str.size());
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_escaped_string(basic_string_view<_CharT> __values,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ basic_string<_CharT> __str;
+ __str += _CharT('"');
+ __formatter::__escape(__str, __values, __escape_quotation_mark::__double_quote);
+ __str += _CharT('"');
+ return __formatter::__write_string(basic_string_view{__str}, _VSTD::move(__out_it), __specs);
+}
+
+# endif // _LIBCPP_STD_VER > 20
+
} // namespace __formatter
#endif //_LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__format/formatter_pointer.h b/libcxx/include/__format/formatter_pointer.h
index 3cd4c9bba960..31b49e17ab47 100644
--- a/libcxx/include/__format/formatter_pointer.h
+++ b/libcxx/include/__format/formatter_pointer.h
@@ -12,7 +12,7 @@
#include <__availability>
#include <__config>
-#include <__format/format_fwd.h>
+#include <__format/concepts.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_integral.h>
@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
public:
constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
@@ -56,13 +56,13 @@ public:
// - struct formatter<nullptr_t, charT>;
// - template<> struct formatter<void*, charT>;
// - template<> struct formatter<const void*, charT>;
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
: public __formatter_pointer<_CharT> {};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
};
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
: public __formatter_pointer<_CharT> {};
diff --git a/libcxx/include/__format/formatter_string.h b/libcxx/include/__format/formatter_string.h
index 71bda4fcded1..606fb792499c 100644
--- a/libcxx/include/__format/formatter_string.h
+++ b/libcxx/include/__format/formatter_string.h
@@ -12,7 +12,7 @@
#include <__availability>
#include <__config>
-#include <__format/format_fwd.h>
+#include <__format/concepts.h>
#include <__format/format_parse_context.h>
#include <__format/formatter.h>
#include <__format/formatter_output.h>
@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS __formatter_string {
public:
_LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
@@ -40,14 +40,23 @@ public:
}
_LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {
+# if _LIBCPP_STD_VER > 20
+ if (__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+# endif
+
return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
}
- __format_spec::__parser<_CharT> __parser_;
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
+# endif
+
+ __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
};
// Formatter const char*.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
: public __formatter_string<_CharT> {
using _Base = __formatter_string<_CharT>;
@@ -56,6 +65,12 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
_LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
"prevented an invalid pointer.");
+ __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
+# if _LIBCPP_STD_VER > 20
+ if (_Base::__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+# endif
+
// 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.
@@ -67,7 +82,6 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
// now these optimizations aren't implemented. Instead the base class
// handles these options.
// TODO FMT Implement these improvements.
- __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
if (__specs.__has_width() || __specs.__has_precision())
return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
@@ -80,7 +94,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
};
// Formatter char*.
-template <__formatter::__char_type _CharT>
+template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
: public formatter<const _CharT*, _CharT> {
using _Base = formatter<const _CharT*, _CharT>;
@@ -91,7 +105,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _Char
};
// Formatter char[].
-template <__formatter::__char_type _CharT, size_t _Size>
+template <__fmt_char_type _CharT, size_t _Size>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
: public __formatter_string<_CharT> {
using _Base = __formatter_string<_CharT>;
@@ -102,7 +116,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size],
};
// Formatter const char[].
-template <__formatter::__char_type _CharT, size_t _Size>
+template <__fmt_char_type _CharT, size_t _Size>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
: public __formatter_string<_CharT> {
using _Base = __formatter_string<_CharT>;
@@ -113,7 +127,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_
};
// Formatter std::string.
-template <__formatter::__char_type _CharT, class _Traits, class _Allocator>
+template <__fmt_char_type _CharT, class _Traits, class _Allocator>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
: public __formatter_string<_CharT> {
using _Base = __formatter_string<_CharT>;
@@ -126,7 +140,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_
};
// Formatter std::string_view.
-template <__formatter::__char_type _CharT, class _Traits>
+template <__fmt_char_type _CharT, class _Traits>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
: public __formatter_string<_CharT> {
using _Base = __formatter_string<_CharT>;
diff --git a/libcxx/include/__format/formatter_tuple.h b/libcxx/include/__format/formatter_tuple.h
new file mode 100644
index 000000000000..82f5ada6e012
--- /dev/null
+++ b/libcxx/include/__format/formatter_tuple.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___FORMAT_FORMATTER_TUPLE_H
+#define _LIBCPP___FORMAT_FORMATTER_TUPLE_H
+
+#include <__algorithm/ranges_copy.h>
+#include <__availability>
+#include <__chrono/statically_widen.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/pair.h>
+#include <string_view>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_tuple {
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
+ __separator_ = __separator;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
+ __opening_bracket_ = __opening_bracket;
+ __closing_bracket_ = __closing_bracket;
+ }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) {
+ const _CharT* __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_tuple);
+
+ // [format.tuple]/7
+ // ... For each element e in underlying_, if e.set_debug_format()
+ // is a valid expression, calls e.set_debug_format().
+ // TODO FMT this can be removed when P2733 is accepted.
+ std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
+ std::__set_debug_format(std::get<_Index>(__underlying_));
+ });
+
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ if (*__begin == _CharT('m')) {
+ if constexpr (sizeof...(_Args) == 2) {
+ set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
+ set_brackets({}, {});
+ ++__begin;
+ } else
+ std::__throw_format_error("The format specifier m requires a pair or a two-element tuple");
+ } else if (*__begin == _CharT('n')) {
+ set_brackets({}, {});
+ ++__begin;
+ }
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ template <class _FormatContext>
+ typename _FormatContext::iterator _LIBCPP_HIDE_FROM_ABI
+ format(conditional_t<(formattable<const _Args, _CharT> && ...), const _Tuple&, _Tuple&> __tuple,
+ _FormatContext& __ctx) const {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+
+ if (!__specs.__has_width())
+ return __format_tuple(__tuple, __ctx);
+
+ basic_string<_CharT> __str;
+
+ // Since the output is written to a different iterator a new context is
+ // created. Since the underlying formatter uses the default formatting it
+ // doesn't need a locale or the formatting arguments. So creating a new
+ // context works.
+ //
+ // This solution works for this formatter, but it will not work for the
+ // range_formatter. In that patch a generic solution is work in progress.
+ // Once that is finished it can be used here. (The range_formatter will use
+ // these features so it's easier to add it there and then port it.)
+ //
+ // TODO FMT Use formatting wrapping used in the range_formatter.
+ basic_format_context __c = std::__format_context_create(
+ back_insert_iterator{__str},
+ basic_format_args<basic_format_context<back_insert_iterator<basic_string<_CharT>>, _CharT>>{});
+
+ __format_tuple(__tuple, __c);
+
+ return __formatter::__write_string_no_precision(basic_string_view{__str}, __ctx.out(), __specs);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_tuple(auto&& __tuple, _FormatContext& __ctx) const {
+ __ctx.advance_to(std::ranges::copy(__opening_bracket_, __ctx.out()).out);
+
+ std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
+ if constexpr (_Index)
+ __ctx.advance_to(std::ranges::copy(__separator_, __ctx.out()).out);
+
+ // During review Victor suggested to make the exposition only
+ // __underlying_ member a local variable. Currently the Standard
+ // requires nested debug-enabled formatter specializations not to
+ // output escaped output. P2733 fixes that bug, once accepted the
+ // code below can be used.
+ // (Note when a paper allows parsing a tuple-underlying-spec the
+ // exposition only member needs to be a class member. Earlier
+ // revisions of P2286 proposed that, but this was not pursued,
+ // due to time constrains and complexity of the matter.)
+ // TODO FMT This can be updated after P2733 is accepted.
+# if 0
+ // P2286 uses an exposition only member in the formatter
+ // tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
+ // This was used in earlier versions of the paper since
+ // __underlying_.parse(...) was called. This is no longer the case
+ // so we can reduce the scope of the formatter.
+ //
+ // It does require the underlying's parse effect to be moved here too.
+ using _Arg = tuple_element<_Index, decltype(__tuple)>;
+ formatter<remove_cvref_t<_Args>, _CharT> __underlying;
+
+ // [format.tuple]/7
+ // ... For each element e in underlying_, if e.set_debug_format()
+ // is a valid expression, calls e.set_debug_format().
+ std::__set_debug_format(__underlying);
+# else
+ __ctx.advance_to(std::get<_Index>(__underlying_).format(std::get<_Index>(__tuple), __ctx));
+# endif
+ });
+
+ return std::ranges::copy(__closing_bracket_, __ctx.out()).out;
+ }
+
+ __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
+
+private:
+ tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
+ basic_string_view<_CharT> __separator_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ", ");
+ basic_string_view<_CharT> __opening_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "(");
+ basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ")");
+};
+
+template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<pair<_Args...>, _CharT>
+ : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {};
+
+template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<tuple<_Args...>, _CharT>
+ : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_TUPLE_H
diff --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h
index 1425a953ebaa..c03cec979636 100644
--- a/libcxx/include/__format/parser_std_format_spec.h
+++ b/libcxx/include/__format/parser_std_format_spec.h
@@ -19,6 +19,8 @@
#include <__algorithm/find_if.h>
#include <__algorithm/min.h>
#include <__assert>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
#include <__config>
#include <__debug>
#include <__format/format_arg.h>
@@ -28,7 +30,6 @@
#include <__format/unicode.h>
#include <__variant/monostate.h>
#include <bit>
-#include <concepts>
#include <cstdint>
#include <string_view>
#include <type_traits>
@@ -52,13 +53,12 @@ __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");
+ std::__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);
+ __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");
+ std::__throw_format_error("Invalid arg-id");
++__r.__ptr;
return __r;
@@ -67,28 +67,33 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
template <class _Context>
_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
__substitute_arg_id(basic_format_arg<_Context> __format_arg) {
- return visit_format_arg(
+ // [format.string.std]/8
+ // If the corresponding formatting argument is not of integral type...
+ // This wording allows char and bool too. LWG-3720 changes the wording to
+ // If the corresponding formatting argument is not of standard signed or
+ // unsigned integer type,
+ // This means the 128-bit will not be valid anymore.
+ // TODO FMT Verify this resolution is accepted and add a test to verify
+ // 128-bit integrals fail and switch to visit_format_arg.
+ return _VSTD::__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");
+ std::__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");
+ std::__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");
+ std::__throw_format_error("Argument index out of bounds");
else
- __throw_format_error("A format-spec arg-id replacement argument "
- "isn't an integral type");
+ std::__throw_format_error("A format-spec arg-id replacement argument isn't an integral type");
},
__format_arg);
}
@@ -97,6 +102,7 @@ __substitute_arg_id(basic_format_arg<_Context> __format_arg) {
///
/// They default to false so when a new field is added it needs to be opted in
/// explicitly.
+// TODO FMT Use an ABI tag for this struct.
struct __fields {
uint8_t __sign_ : 1 {false};
uint8_t __alternate_form_ : 1 {false};
@@ -104,6 +110,13 @@ struct __fields {
uint8_t __precision_ : 1 {false};
uint8_t __locale_specific_form_ : 1 {false};
uint8_t __type_ : 1 {false};
+ // Determines the valid values for fill.
+ //
+ // Originally the fill could be any character except { and }. Range-based
+ // formatters use the colon to mark the beginning of the
+ // underlying-format-spec. To avoid parsing ambiguities these formatter
+ // specializations prohibit the use of the colon as a fill character.
+ uint8_t __allow_colon_in_fill_ : 1 {false};
};
// By not placing this constant in the formatter class it's not duplicated for
@@ -124,6 +137,11 @@ inline constexpr __fields __fields_floating_point{
inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
inline constexpr __fields __fields_pointer{.__type_ = true};
+# if _LIBCPP_STD_VER > 20
+inline constexpr __fields __fields_tuple{.__type_ = false, .__allow_colon_in_fill_ = true};
+inline constexpr __fields __fields_range{.__type_ = false, .__allow_colon_in_fill_ = true};
+# endif
+
enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
/// No alignment is set in the format string.
__default,
@@ -163,7 +181,8 @@ enum class _LIBCPP_ENUM_VIS __type : uint8_t {
__fixed_lower_case,
__fixed_upper_case,
__general_lower_case,
- __general_upper_case
+ __general_upper_case,
+ __debug
};
struct __std {
@@ -176,7 +195,11 @@ struct __std {
struct __chrono {
__alignment __alignment_ : 3;
+ bool __locale_specific_form_ : 1;
bool __weekday_name_ : 1;
+ bool __weekday_ : 1;
+ bool __day_of_year_ : 1;
+ bool __week_of_year_ : 1;
bool __month_name_ : 1;
};
@@ -250,7 +273,7 @@ public:
if (__begin == __end)
return __begin;
- if (__parse_fill_align(__begin, __end) && __begin == __end)
+ if (__parse_fill_align(__begin, __end, __fields.__allow_colon_in_fill_) && __begin == __end)
return __begin;
if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
@@ -278,7 +301,7 @@ public:
// parsing. In that case that parser should do the end of format string
// validation.
if (__begin != __end && *__begin != _CharT('}'))
- __throw_format_error("The format-spec should consume the input or end with a '}'");
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
}
return __begin;
@@ -288,12 +311,26 @@ public:
_LIBCPP_HIDE_FROM_ABI
__parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
return __parsed_specifications<_CharT>{
- .__std_ =
- __std{.__alignment_ = __alignment_,
- .__sign_ = __sign_,
- .__alternate_form_ = __alternate_form_,
- .__locale_specific_form_ = __locale_specific_form_,
- .__type_ = __type_},
+ .__std_ = __std{.__alignment_ = __alignment_,
+ .__sign_ = __sign_,
+ .__alternate_form_ = __alternate_form_,
+ .__locale_specific_form_ = __locale_specific_form_,
+ .__type_ = __type_},
+ .__width_{__get_width(__ctx)},
+ .__precision_{__get_precision(__ctx)},
+ .__fill_{__fill_}};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __parsed_specifications<_CharT> __get_parsed_chrono_specifications(auto& __ctx) const {
+ return __parsed_specifications<_CharT>{
+ .__chrono_ =
+ __chrono{.__alignment_ = __alignment_,
+ .__locale_specific_form_ = __locale_specific_form_,
+ .__weekday_name_ = __weekday_name_,
+ .__weekday_ = __weekday_,
+ .__day_of_year_ = __day_of_year_,
+ .__week_of_year_ = __week_of_year_,
+ .__month_name_ = __month_name_},
.__width_{__get_width(__ctx)},
.__precision_{__get_precision(__ctx)},
.__fill_{__fill_}};
@@ -306,12 +343,17 @@ public:
bool __reserved_0_ : 1 {false};
__type __type_{__type::__default};
- // These two flags are used for formatting chrono. Since the struct has
+ // These flags are only used for formatting chrono. Since the struct has
// padding space left it's added to this structure.
bool __weekday_name_ : 1 {false};
+ bool __weekday_ : 1 {false};
+
+ bool __day_of_year_ : 1 {false};
+ bool __week_of_year_ : 1 {false};
+
bool __month_name_ : 1 {false};
- uint8_t __reserved_1_ : 6 {0};
+ uint8_t __reserved_1_ : 3 {0};
uint8_t __reserved_2_ : 6 {0};
// These two flags are only used internally and not part of the
// __parsed_specifications. Therefore put them at the end.
@@ -348,13 +390,17 @@ private:
return false;
}
- _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) {
+ // range-fill and tuple-fill are identical
+ _LIBCPP_HIDE_FROM_ABI constexpr bool
+ __parse_fill_align(const _CharT*& __begin, const _CharT* __end, bool __use_range_fill) {
_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 (__parse_alignment(*(__begin + 1))) {
- if (*__begin == _CharT('{') || *__begin == _CharT('}'))
- __throw_format_error("The format-spec fill field contains an invalid character");
+ if (__use_range_fill && (*__begin == _CharT('{') || *__begin == _CharT('}') || *__begin == _CharT(':')))
+ std::__throw_format_error("The format-spec range-fill field contains an invalid character");
+ else if (*__begin == _CharT('{') || *__begin == _CharT('}'))
+ std::__throw_format_error("The format-spec fill field contains an invalid character");
__fill_ = *__begin;
__begin += 2;
@@ -408,7 +454,7 @@ private:
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(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");
+ std::__throw_format_error("A format-spec width field shouldn't have a leading zero");
if (*__begin == _CharT('{')) {
__format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
@@ -436,7 +482,7 @@ private:
++__begin;
if (__begin == __end)
- __throw_format_error("End of input while parsing format-spec precision");
+ std::__throw_format_error("End of input while parsing format-spec precision");
if (*__begin == _CharT('{')) {
__format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
@@ -447,7 +493,7 @@ private:
}
if (*__begin < _CharT('0') || *__begin > _CharT('9'))
- __throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
+ std::__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;
@@ -523,6 +569,11 @@ private:
case 'x':
__type_ = __type::__hexadecimal_lower_case;
break;
+# if _LIBCPP_STD_VER > 20
+ case '?':
+ __type_ = __type::__debug;
+ break;
+# endif
default:
return;
}
@@ -534,10 +585,7 @@ private:
if (!__width_as_arg_)
return __width_;
- int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));
- if (__result == 0)
- __throw_format_error("A format-spec width field replacement should have a positive value");
- return __result;
+ return __format_spec::__substitute_arg_id(__ctx.arg(__width_));
}
_LIBCPP_HIDE_FROM_ABI
@@ -559,6 +607,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec
switch (__type) {
case __format_spec::__type::__default:
case __format_spec::__type::__string:
+ case __format_spec::__type::__debug:
break;
default:
@@ -612,6 +661,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __p
switch (__parser.__type_) {
case __format_spec::__type::__default:
case __format_spec::__type::__char:
+ case __format_spec::__type::__debug:
__format_spec::__process_display_type_char(__parser);
break;
@@ -653,11 +703,6 @@ template <class _CharT>
_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
switch (__parser.__type_) {
case __format_spec::__type::__default:
- // When no precision specified then it keeps default since that
- // formatting differs from the other types.
- if (__parser.__precision_as_arg_ || __parser.__precision_ != -1)
- __parser.__type_ = __format_spec::__type::__general_lower_case;
- break;
case __format_spec::__type::__hexfloat_lower_case:
case __format_spec::__type::__hexfloat_upper_case:
// Precision specific behavior will be handled later.
@@ -699,6 +744,9 @@ struct __column_width_result {
const _CharT* __last_;
};
+template <class _CharT>
+__column_width_result(size_t, const _CharT*) -> __column_width_result<_CharT>;
+
/// Since a column width can be two it's possible that the requested column
/// width can't be achieved. Depending on the intended usage the policy can be
/// selected.
@@ -857,7 +905,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
// unit is non-ASCII we omit the current code unit and let the Grapheme
// clustering algorithm do its work.
const _CharT* __it = __str.begin();
- if (__is_ascii(*__it)) {
+ if (__format_spec::__is_ascii(*__it)) {
do {
--__maximum;
++__it;
@@ -865,12 +913,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
return {__str.size(), __str.end()};
if (__maximum == 0) {
- if (__is_ascii(*__it))
+ if (__format_spec::__is_ascii(*__it))
return {static_cast<size_t>(__it - __str.begin()), __it};
break;
}
- } while (__is_ascii(*__it));
+ } while (__format_spec::__is_ascii(*__it));
--__it;
++__maximum;
}
diff --git a/libcxx/include/__format/range_default_formatter.h b/libcxx/include/__format/range_default_formatter.h
new file mode 100644
index 000000000000..774887b05305
--- /dev/null
+++ b/libcxx/include/__format/range_default_formatter.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___FORMAT_RANGE_DEFAULT_FORMATTER_H
+#define _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__availability>
+#include <__chrono/statically_widen.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/formatter.h>
+#include <__format/range_formatter.h>
+#include <__ranges/concepts.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/pair.h>
+#include <string_view>
+#include <tuple>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <class _Rp, class _CharT>
+concept __const_formattable_range =
+ ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;
+
+template <class _Rp, class _CharT>
+using __fmt_maybe_const = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;
+
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow")
+// This shadows map, set, and string.
+enum class range_format { disabled, map, set, sequence, string, debug_string };
+_LIBCPP_DIAGNOSTIC_POP
+
+// There is no definition of this struct, it's purely intended to be used to
+// generate diagnostics.
+template <class _Rp>
+struct _LIBCPP_TEMPLATE_VIS __instantiated_the_primary_template_of_format_kind;
+
+template <class _Rp>
+constexpr range_format format_kind = [] {
+ // [format.range.fmtkind]/1
+ // A program that instantiates the primary template of format_kind is ill-formed.
+ static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type");
+ return range_format::disabled;
+}();
+
+template <ranges::input_range _Rp>
+ requires same_as<_Rp, remove_cvref_t<_Rp>>
+inline constexpr range_format format_kind<_Rp> = [] {
+ // [format.range.fmtkind]/2
+
+ // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true,
+ // Otherwise format_kind<R> is range_format::disabled.
+ if constexpr (same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Rp>)
+ return range_format::disabled;
+ // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type:
+ else if constexpr (requires { typename _Rp::key_type; }) {
+ // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ...
+ if constexpr (requires { typename _Rp::mapped_type; } &&
+ // 2.2.1 ... If either U is a specialization of pair or U is a specialization
+ // of tuple and tuple_size_v<U> == 2
+ __fmt_pair_like<remove_cvref_t<ranges::range_reference_t<_Rp>>>)
+ return range_format::map;
+ else
+ // 2.2.2 Otherwise format_kind<R> is range_format::set.
+ return range_format::set;
+ } else
+ // 2.3 Otherwise, format_kind<R> is range_format::sequence.
+ return range_format::sequence;
+}();
+
+// This is a non-standard work-around to fix instantiation of
+// formatter<const _CharT[N], _CharT>
+// const _CharT[N] satisfies the ranges::input_range concept.
+// remove_cvref_t<const _CharT[N]> is _CharT[N] so it does not satisfy the
+// requirement of the above specialization. Instead it will instantiate the
+// primary template, which is ill-formed.
+//
+// An alternative solution is to remove the offending formatter.
+//
+// https://godbolt.org/z/bqjhhaexx
+//
+// The removal is proposed in LWG3833, but use the work-around until the issue
+// has been adopted.
+// TODO FMT Implement LWG3833.
+template <class _CharT, size_t N>
+inline constexpr range_format format_kind<const _CharT[N]> = range_format::disabled;
+
+template <range_format _Kp, ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter;
+
+// Required specializations
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::sequence, _Rp, _CharT> {
+private:
+ using __maybe_const_r = __fmt_maybe_const<_Rp, _CharT>;
+ range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
+ __underlying_.set_separator(__separator);
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
+ __underlying_.set_brackets(__opening_bracket, __closing_bracket);
+ }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename FormatContext::iterator format(__maybe_const_r& __range, FormatContext& __ctx) const {
+ return __underlying_.format(__range, __ctx);
+ }
+};
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::map, _Rp, _CharT> {
+private:
+ using __maybe_const_map = __fmt_maybe_const<_Rp, _CharT>;
+ using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;
+ range_formatter<__element_type, _CharT> __underlying_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr __range_default_formatter()
+ requires(__fmt_pair_like<__element_type>)
+ {
+ __underlying_.set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
+ __underlying_.underlying().set_brackets({}, {});
+ __underlying_.underlying().set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
+ }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
+ format(__maybe_const_map& __range, _FormatContext& __ctx) const {
+ return __underlying_.format(__range, __ctx);
+ }
+};
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::set, _Rp, _CharT> {
+private:
+ using __maybe_const_set = __fmt_maybe_const<_Rp, _CharT>;
+ using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;
+ range_formatter<__element_type, _CharT> __underlying_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr __range_default_formatter() {
+ __underlying_.set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
+ }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
+ format(__maybe_const_set& __range, _FormatContext& __ctx) const {
+ return __underlying_.format(__range, __ctx);
+ }
+};
+
+template <range_format _Kp, ranges::input_range _Rp, class _CharT>
+ requires(_Kp == range_format::string || _Kp == range_format::debug_string)
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<_Kp, _Rp, _CharT> {
+ __range_default_formatter() = delete; // TODO FMT Implement
+};
+
+template <ranges::input_range _Rp, class _CharT>
+ requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Rp, _CharT>
+ : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
diff --git a/libcxx/include/__format/range_formatter.h b/libcxx/include/__format/range_formatter.h
new file mode 100644
index 000000000000..9ea61a70350a
--- /dev/null
+++ b/libcxx/include/__format/range_formatter.h
@@ -0,0 +1,255 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_RANGE_FORMATTER_H
+#define _LIBCPP___FORMAT_RANGE_FORMATTER_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__algorithm/ranges_copy.h>
+#include <__availability>
+#include <__chrono/statically_widen.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/buffer.h>
+#include <__format/concepts.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.h>
+#include <__format/formatter.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/size.h>
+#include <__type_traits/remove_cvref.h>
+#include <string_view>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <class _Tp, class _CharT = char>
+ requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT range_formatter {
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
+ __separator_ = __separator;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
+ __opening_bracket_ = __opening_bracket;
+ __closing_bracket_ = __closing_bracket;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr formatter<_Tp, _CharT>& underlying() { return __underlying_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const formatter<_Tp, _CharT>& underlying() const { return __underlying_; }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) {
+ const _CharT* __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_range);
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ // The n field overrides a possible m type, therefore delay applying the
+ // effect of n until the type has been procesed.
+ bool __clear_brackets = (*__begin == _CharT('n'));
+ if (__clear_brackets) {
+ ++__begin;
+ if (__begin == __end) {
+ // Since there is no more data, clear the brackets before returning.
+ set_brackets({}, {});
+ return __begin;
+ }
+ }
+
+ __parse_type(__begin, __end);
+ if (__clear_brackets)
+ set_brackets({}, {});
+ if (__begin == __end)
+ return __begin;
+
+ bool __has_range_underlying_spec = *__begin == _CharT(':');
+ if (__parser_.__type_ != __format_spec::__type::__default) {
+ // [format.range.formatter]/6
+ // If the range-type is s or ?s, then there shall be no n option and no
+ // range-underlying-spec.
+ if (__clear_brackets) {
+ if (__parser_.__type_ == __format_spec::__type::__string)
+ std::__throw_format_error("The n option and type s can't be used together");
+ std::__throw_format_error("The n option and type ?s can't be used together");
+ }
+ if (__has_range_underlying_spec) {
+ if (__parser_.__type_ == __format_spec::__type::__string)
+ std::__throw_format_error("Type s and an underlying format specification can't be used together");
+ std::__throw_format_error("Type ?s and an underlying format specification can't be used together");
+ }
+ } else if (!__has_range_underlying_spec)
+ std::__set_debug_format(__underlying_);
+
+ if (__has_range_underlying_spec) {
+ // range-underlying-spec:
+ // : format-spec
+ ++__begin;
+ if (__begin == __end)
+ return __begin;
+
+ __parse_ctx.advance_to(__begin);
+ __begin = __underlying_.parse(__parse_ctx);
+ }
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ template <ranges::input_range _Rp, class _FormatContext>
+ requires formattable<ranges::range_reference_t<_Rp>, _CharT> &&
+ same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Tp>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_Rp&& __range, _FormatContext& __ctx) const {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+
+ if (!__specs.__has_width())
+ return __format_range(__range, __ctx, __specs);
+
+ // The size of the buffer needed is:
+ // - open bracket characters
+ // - close bracket character
+ // - n elements where every element may have a different size
+ // - (n -1) separators
+ // The size of the element is hard to predict, knowing the type helps but
+ // it depends on the format-spec. As an initial estimate we guess 6
+ // characters.
+ // Typically both brackets are 1 character and the separator is 2
+ // characters. Which means there will be
+ // (n - 1) * 2 + 1 + 1 = n * 2 character
+ // So estimate 8 times the range size as buffer.
+ std::size_t __capacity_hint = 0;
+ if constexpr (std::ranges::sized_range<_Rp>)
+ __capacity_hint = 8 * ranges::size(__range);
+ __format::__retarget_buffer<_CharT> __buffer{__capacity_hint};
+ basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> __c{
+ __buffer.__make_output_iterator(), __ctx};
+
+ __format_range(__range, __c, __specs);
+
+ return __formatter::__write_string_no_precision(__buffer.__view(), __ctx.out(), __specs);
+ }
+
+ template <ranges::input_range _Rp, class _FormatContext>
+ typename _FormatContext::iterator _LIBCPP_HIDE_FROM_ABI
+ __format_range(_Rp&& __range, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) const {
+ if constexpr (same_as<_Tp, _CharT>) {
+ switch (__specs.__std_.__type_) {
+ case __format_spec::__type::__string:
+ case __format_spec::__type::__debug:
+ return __format_as_string(__range, __ctx, __specs.__std_.__type_ == __format_spec::__type::__debug);
+ default:
+ return __format_as_sequence(__range, __ctx);
+ }
+ } else
+ return __format_as_sequence(__range, __ctx);
+ }
+
+ template <ranges::input_range _Rp, class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
+ __format_as_string(_Rp&& __range, _FormatContext& __ctx, bool __debug_format) const {
+ // When the range is contiguous use a basic_string_view instead to avoid a
+ // copy of the underlying data. The basic_string_view formatter
+ // specialization is the "basic" string formatter in libc++.
+ if constexpr (ranges::contiguous_range<_Rp> && std::ranges::sized_range<_Rp>) {
+ std::formatter<basic_string_view<_CharT>, _CharT> __formatter;
+ if (__debug_format)
+ __formatter.set_debug_format();
+ return __formatter.format(
+ basic_string_view<_CharT>{
+ ranges::data(__range),
+ ranges::size(__range),
+ },
+ __ctx);
+ } else {
+ std::formatter<basic_string<_CharT>, _CharT> __formatter;
+ if (__debug_format)
+ __formatter.set_debug_format();
+ // P2106's from_range has not been implemented yet. Instead use a simple
+ // copy operation.
+ // TODO FMT use basic_string's "from_range" constructor.
+ // return std::formatter<basic_string<_CharT>, _CharT>{}.format(basic_string<_CharT>{from_range, __range}, __ctx);
+ basic_string<_CharT> __str;
+ ranges::copy(__range, back_insert_iterator{__str});
+ return __formatter.format(__str, __ctx);
+ }
+ }
+
+ template <ranges::input_range _Rp, class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
+ __format_as_sequence(_Rp&& __range, _FormatContext& __ctx) const {
+ __ctx.advance_to(ranges::copy(__opening_bracket_, __ctx.out()).out);
+ bool __use_separator = false;
+ for (auto&& __e : __range) {
+ if (__use_separator)
+ __ctx.advance_to(ranges::copy(__separator_, __ctx.out()).out);
+ else
+ __use_separator = true;
+
+ __ctx.advance_to(__underlying_.format(__e, __ctx));
+ }
+
+ return ranges::copy(__closing_bracket_, __ctx.out()).out;
+ }
+
+ __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
+
+private:
+ _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin, const _CharT* __end) {
+ switch (*__begin) {
+ case _CharT('m'):
+ if constexpr (__fmt_pair_like<_Tp>) {
+ set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
+ set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ", "));
+ ++__begin;
+ } else
+ std::__throw_format_error("The range-format-spec type m requires two elements for a pair or tuple");
+ break;
+
+ case _CharT('s'):
+ if constexpr (same_as<_Tp, _CharT>) {
+ __parser_.__type_ = __format_spec::__type::__string;
+ ++__begin;
+ } else
+ std::__throw_format_error("The range-format-spec type s requires formatting a character type");
+ break;
+
+ case _CharT('?'):
+ ++__begin;
+ if (__begin == __end || *__begin != _CharT('s'))
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
+ if constexpr (same_as<_Tp, _CharT>) {
+ __parser_.__type_ = __format_spec::__type::__debug;
+ ++__begin;
+ } else
+ std::__throw_format_error("The range-format-spec type ?s requires formatting a character type");
+ }
+ }
+
+ formatter<_Tp, _CharT> __underlying_;
+ basic_string_view<_CharT> __separator_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ", ");
+ basic_string_view<_CharT> __opening_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "[");
+ basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]");
+};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_RANGE_FORMATTER_H
diff --git a/libcxx/include/__format/unicode.h b/libcxx/include/__format/unicode.h
index 3316217f4a1e..432725876082 100644
--- a/libcxx/include/__format/unicode.h
+++ b/libcxx/include/__format/unicode.h
@@ -13,6 +13,7 @@
#include <__assert>
#include <__config>
#include <__format/extended_grapheme_cluster_table.h>
+#include <__type_traits/make_unsigned.h>
#include <__utility/unreachable.h>
#include <bit>
@@ -24,6 +25,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
+namespace __unicode {
+
+# if _LIBCPP_STD_VER > 20
+
+/// The result of consuming a code point using P2286' semantics
+///
+/// TODO FMT Combine __consume and __consume_p2286 in one function.
+struct __consume_p2286_result {
+ // A size of 0 means well formed. This to differenciate between
+ // a valid code point and a code unit that's invalid like 0b11111xxx.
+ int __ill_formed_size;
+
+ // If well formed the consumed code point.
+ // Otherwise the ill-formed code units as unsigned 8-bit values. They are
+ // stored in reverse order, to make it easier to extract the values.
+ char32_t __value;
+};
+
+# endif // _LIBCPP_STD_VER > 20
+
# ifndef _LIBCPP_HAS_NO_UNICODE
/// Implements the grapheme cluster boundary rules
@@ -39,8 +60,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
-namespace __unicode {
-
inline constexpr char32_t __replacement_character = U'\ufffd';
_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
@@ -123,18 +142,92 @@ public:
return __replacement_character;
}
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ // 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 (std::countl_one(static_cast<unsigned char>(*__first_))) {
+ case 0:
+ return {0, static_cast<unsigned char>(*__first_++)};
+
+ case 2:
+ if (__last_ - __first_ < 2) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 1)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return {0, __value};
+ }
+ break;
+
+ case 3:
+ if (__last_ - __first_ < 3) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 2)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return {0, __value};
+ }
+ break;
+
+ case 4:
+ if (__last_ - __first_ < 4) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 3)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+
+ if (__value > 0x10FFFF) // Outside the valid Unicode range?
+ return {4, __value};
+
+ return {0, __value};
+ }
+ break;
+ }
+ // An invalid number of leading ones can be garbage or a code unit in the
+ // middle of a code point. By consuming one code unit the parser may get
+ // "in sync" after a few code units.
+ return {1, static_cast<unsigned char>(*__first_++)};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
private:
const char* __first_;
const char* __last_;
};
-# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) {
+ return __value >= 0xd800 && __value <= 0xdbff;
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) {
+ return __value >= 0xdc00 && __value <= 0xdfff;
+}
+
/// This specialization depends on the size of wchar_t
/// - 2 UTF-16 (for example Windows and AIX)
/// - 4 UTF-32 (for example Linux)
template <>
class __code_point_view<wchar_t> {
public:
+ static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
+
_LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
: __first_(__first), __last_(__last) {}
@@ -166,17 +259,43 @@ public:
return __replacement_character;
return __result;
} else {
- // TODO FMT P2593R0 Use static_assert(false, "sizeof(wchar_t) has a not implemented value");
- _LIBCPP_ASSERT(sizeof(wchar_t) == 0, "sizeof(wchar_t) has a not implemented value");
__libcpp_unreachable();
}
}
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ char32_t __result = *__first_++;
+ if constexpr (sizeof(wchar_t) == 2) {
+ // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ if (__is_surrogate_pair_high(__result)) {
+ // Malformed Unicode.
+ if (__first_ == __last_ || !__is_surrogate_pair_low(*(__first_ + 1))) [[unlikely]]
+ return {1, __result};
+
+ __result -= 0xd800;
+ __result <<= 10;
+ __result += *__first_++ - 0xdc00;
+ __result += 0x10000;
+ } else if (__is_surrogate_pair_low(__result))
+ // A code point shouldn't start with the low surrogate pair
+ return {1, __result};
+ } else {
+ if (__result > 0x10FFFF) [[unlikely]]
+ return {1, __result};
+ }
+
+ return {0, __result};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
private:
const wchar_t* __first_;
const wchar_t* __last_;
};
-# endif
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
bool& __ri_break_allowed,
@@ -251,10 +370,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
__ri_break_allowed = !__ri_break_allowed;
- if (__ri_break_allowed)
- return true;
-
- return false;
+ return __ri_break_allowed;
}
// *** Otherwise, break everywhere. ***
@@ -328,10 +444,44 @@ private:
}
};
-} // namespace __unicode
+template <class _CharT>
+__extended_grapheme_cluster_view(const _CharT*, const _CharT*) -> __extended_grapheme_cluster_view<_CharT>;
+
+# else // _LIBCPP_HAS_NO_UNICODE
+
+// For ASCII every character is a "code point".
+// This makes it easier to write code agnostic of the _LIBCPP_HAS_NO_UNICODE define.
+template <class _CharT>
+class __code_point_view {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const _CharT* __first, const _CharT* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __position() const noexcept { return __first_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+ return *__first_++;
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ return {0, std::make_unsigned_t<_CharT>(*__first_++)};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
+private:
+ const _CharT* __first_;
+ const _CharT* __last_;
+};
# endif // _LIBCPP_HAS_NO_UNICODE
+} // namespace __unicode
+
#endif //_LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__functional/binary_negate.h b/libcxx/include/__functional/binary_negate.h
index c4977f4ebe12..73ecea997100 100644
--- a/libcxx/include/__functional/binary_negate.h
+++ b/libcxx/include/__functional/binary_negate.h
@@ -29,17 +29,17 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
{
_Predicate __pred_;
public:
- _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_SINCE_CXX14
binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
binary_negate<_Predicate>
not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
diff --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h
index d1cbbb3d916e..297e4e5103a3 100644
--- a/libcxx/include/__functional/bind.h
+++ b/libcxx/include/__functional/bind.h
@@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp>
struct is_bind_expression : _If<
- _IsSame<_Tp, __uncvref_t<_Tp> >::value,
+ _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
false_type,
- is_bind_expression<__uncvref_t<_Tp> >
+ is_bind_expression<__remove_cvref_t<_Tp> >
> {};
#if _LIBCPP_STD_VER > 14
@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
template<class _Tp>
struct is_placeholder : _If<
- _IsSame<_Tp, __uncvref_t<_Tp> >::value,
+ _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
integral_constant<int, 0>,
- is_placeholder<__uncvref_t<_Tp> >
+ is_placeholder<__remove_cvref_t<_Tp> >
> {};
#if _LIBCPP_STD_VER > 14
@@ -279,16 +279,16 @@ public:
class = typename enable_if
<
is_constructible<_Fd, _Gp>::value &&
- !is_same<typename remove_reference<_Gp>::type,
+ !is_same<__libcpp_remove_reference_t<_Gp>,
__bind>::value
>::type>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args)
{
@@ -297,7 +297,7 @@ public:
}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args) const
{
@@ -324,16 +324,16 @@ public:
class = typename enable_if
<
is_constructible<_Fd, _Gp>::value &&
- !is_same<typename remove_reference<_Gp>::type,
+ !is_same<__libcpp_remove_reference_t<_Gp>,
__bind_r>::value
>::type>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
@@ -347,7 +347,7 @@ public:
}
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
@@ -365,7 +365,7 @@ 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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
@@ -374,7 +374,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
}
template<class _Rp, class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
diff --git a/libcxx/include/__functional/boyer_moore_searcher.h b/libcxx/include/__functional/boyer_moore_searcher.h
index 20e554408ff0..a6750893ee57 100644
--- a/libcxx/include/__functional/boyer_moore_searcher.h
+++ b/libcxx/include/__functional/boyer_moore_searcher.h
@@ -223,6 +223,7 @@ private:
}
}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
@@ -303,6 +304,7 @@ private:
return std::make_pair(__l, __l);
}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_horspool_searcher);
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__functional/default_searcher.h b/libcxx/include/__functional/default_searcher.h
index 8e37082b6bed..e4151e589f78 100644
--- a/libcxx/include/__functional/default_searcher.h
+++ b/libcxx/include/__functional/default_searcher.h
@@ -29,13 +29,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
class _LIBCPP_TEMPLATE_VIS default_searcher {
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
pair<_ForwardIterator2, _ForwardIterator2>
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
@@ -48,6 +48,7 @@ private:
_ForwardIterator __last_;
_BinaryPredicate __pred_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(default_searcher);
#endif // _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index db3af6e24101..ca79d334a028 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -17,20 +17,29 @@
#include <__functional/unary_function.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_destructor.h>
#include <__memory/allocator_traits.h>
+#include <__memory/builtin_new_allocator.h>
#include <__memory/compressed_pair.h>
-#include <__memory/shared_ptr.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/strip_signature.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
#include <exception>
-#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
+#include <new>
+#include <tuple>
#include <type_traits>
+#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+#ifndef _LIBCPP_CXX03_LANG
+
_LIBCPP_BEGIN_NAMESPACE_STD
// bad_function_call
@@ -45,13 +54,13 @@ public:
// 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;
+ ~bad_function_call() _NOEXCEPT override;
#else
- virtual ~bad_function_call() _NOEXCEPT {}
+ ~bad_function_call() _NOEXCEPT override {}
#endif
#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
- virtual const char* what() const _NOEXCEPT;
+ const char* what() const _NOEXCEPT override;
#endif
};
_LIBCPP_DIAGNOSTIC_POP
@@ -66,14 +75,7 @@ void __throw_bad_function_call()
#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
+template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
namespace __function
{
@@ -124,8 +126,6 @@ bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
} // namespace __function
-#ifndef _LIBCPP_CXX03_LANG
-
namespace __function {
// __alloc_func holds a functor and an allocator.
@@ -190,9 +190,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
__alloc_func* __clone() const
{
typedef allocator_traits<_Alloc> __alloc_traits;
- typedef
- typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
- _AA;
+ typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;
_AA __a(__f_.second());
typedef __allocator_destructor<_AA> _Dp;
unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -205,8 +203,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
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;
+ typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc;
_FunAlloc __a(__f->__get_allocator());
__f->destroy();
__a.deallocate(__f, 1);
@@ -265,7 +262,7 @@ class __base<_Rp(_ArgTypes...)>
__base& operator=(const __base&);
public:
_LIBCPP_INLINE_VISIBILITY __base() {}
- _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
virtual __base* __clone() const = 0;
virtual void __clone(__base*) const = 0;
virtual void destroy() _NOEXCEPT = 0;
@@ -319,7 +316,7 @@ __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;
+ typedef __rebind_alloc<__alloc_traits, __func> _Ap;
_Ap __a(__f_.__get_allocator());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -346,7 +343,7 @@ 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;
+ typedef __rebind_alloc<__alloc_traits, __func> _Ap;
_Ap __a(__f_.__get_allocator());
__f_.destroy();
__a.deallocate(this, 1);
@@ -385,7 +382,9 @@ template <class _Fp> class __value_func;
template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<3 * sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
typedef __base<_Rp(_ArgTypes...)> __func;
__func* __f_;
@@ -405,8 +404,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
- typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
- _FunAlloc;
+ typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
if (__function::__not_null(__f))
{
@@ -519,7 +517,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
return;
if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__func* __t = __as_base(&__tempbuf);
__f_->__clone(__t);
__f_->destroy();
@@ -670,8 +670,7 @@ struct __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;
+using __fast_forward = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
// __policy_invoker calls an instance of __alloc_func held in __policy_storage.
@@ -747,8 +746,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
{
typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
- _FunAlloc;
+ typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
if (__function::__not_null(__f))
{
@@ -883,7 +881,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
#endif // _LIBCPP_NO_RTTI
};
-#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
+#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME)
extern "C" void *_Block_copy(const void *);
extern "C" void _Block_release(const void *);
@@ -898,14 +896,22 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
public:
_LIBCPP_INLINE_VISIBILITY
explicit __func(__block_type const& __f)
+#ifdef _LIBCPP_HAS_OBJC_ARC
+ : __f_(__f)
+#else
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
+#endif
{ }
// [TODO] add && to save on a retain
_LIBCPP_INLINE_VISIBILITY
explicit __func(__block_type __f, const _Alloc& /* unused */)
+#ifdef _LIBCPP_HAS_OBJC_ARC
+ : __f_(__f)
+#else
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
+#endif
{ }
virtual __base<_Rp(_ArgTypes...)>* __clone() const {
@@ -921,8 +927,10 @@ public:
}
virtual void destroy() _NOEXCEPT {
+#ifndef _LIBCPP_HAS_OBJC_ARC
if (__f_)
_Block_release(__f_);
+#endif
__f_ = 0;
}
@@ -950,7 +958,7 @@ public:
#endif // _LIBCPP_NO_RTTI
};
-#endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC
+#endif // _LIBCPP_HAS_EXTENSION_BLOCKS
} // namespace __function
@@ -968,7 +976,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
__func __f_;
template <class _Fp, bool = _And<
- _IsNotSame<__uncvref_t<_Fp>, function>,
+ _IsNotSame<__remove_cvref_t<_Fp>, function>,
__invokable<_Fp, _ArgTypes...>
>::value>
struct __callable;
@@ -1060,45 +1068,6 @@ public:
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
@@ -1240,1574 +1209,8 @@ void
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{return __x.swap(__y);}
-#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)
-
-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);}
+_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CXX03_LANG
-_LIBCPP_END_NAMESPACE_STD
-
#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 8a11931288cf..dfd8ea2553dc 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -10,8 +10,15 @@
#define _LIBCPP___FUNCTIONAL_HASH_H
#include <__config>
+#include <__functional/invoke.h>
#include <__functional/unary_function.h>
-#include <__tuple>
+#include <__fwd/hash.h>
+#include <__tuple_dir/sfinae_helpers.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/underlying_type.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/pair.h>
@@ -20,7 +27,6 @@
#include <cstdint>
#include <cstring>
#include <limits>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -62,7 +68,7 @@ __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
const unsigned char* __data = static_cast<const unsigned char*>(__key);
for (; __len >= 4; __data += 4, __len -= 4)
{
- _Size __k = __loadword<_Size>(__data);
+ _Size __k = std::__loadword<_Size>(__data);
__k *= __m;
__k ^= __k >> __r;
__k *= __m;
@@ -127,14 +133,14 @@ struct __murmur2_or_cityhash<_Size, 64>
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
if (__len > 8) {
- const _Size __a = __loadword<_Size>(__s);
- const _Size __b = __loadword<_Size>(__s + __len - 8);
+ const _Size __a = std::__loadword<_Size>(__s);
+ const _Size __b = std::__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);
+ const uint32_t __a = std::__loadword<uint32_t>(__s);
+ const uint32_t __b = std::__loadword<uint32_t>(__s + __len - 4);
+ return __hash_len_16(__len + (static_cast<_Size>(__a) << 3), __b);
}
if (__len > 0) {
const unsigned char __a = static_cast<unsigned char>(__s[0]);
@@ -151,10 +157,10 @@ struct __murmur2_or_cityhash<_Size, 64>
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;
+ const _Size __a = std::__loadword<_Size>(__s) * __k1;
+ const _Size __b = std::__loadword<_Size>(__s + 8);
+ const _Size __c = std::__loadword<_Size>(__s + __len - 8) * __k2;
+ const _Size __d = std::__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);
}
@@ -179,10 +185,10 @@ struct __murmur2_or_cityhash<_Size, 64>
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),
+ return __weak_hash_len_32_with_seeds(std::__loadword<_Size>(__s),
+ std::__loadword<_Size>(__s + 8),
+ std::__loadword<_Size>(__s + 16),
+ std::__loadword<_Size>(__s + 24),
__a,
__b);
}
@@ -191,23 +197,23 @@ struct __murmur2_or_cityhash<_Size, 64>
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 __z = std::__loadword<_Size>(__s + 24);
+ _Size __a = std::__loadword<_Size>(__s) +
+ (__len + std::__loadword<_Size>(__s + __len - 16)) * __k0;
_Size __b = __rotate(__a + __z, 52);
_Size __c = __rotate(__a, 37);
- __a += __loadword<_Size>(__s + 8);
+ __a += std::__loadword<_Size>(__s + 8);
__c += __rotate(__a, 7);
- __a += __loadword<_Size>(__s + 16);
+ __a += std::__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);
+ __a = std::__loadword<_Size>(__s + 16) + std::__loadword<_Size>(__s + __len - 32);
+ __z += std::__loadword<_Size>(__s + __len - 8);
__b = __rotate(__a + __z, 52);
__c = __rotate(__a, 37);
- __a += __loadword<_Size>(__s + __len - 24);
+ __a += std::__loadword<_Size>(__s + __len - 24);
__c += __rotate(__a, 7);
- __a += __loadword<_Size>(__s + __len - 16);
+ __a += std::__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);
@@ -233,26 +239,26 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __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));
+ _Size __x = std::__loadword<_Size>(__s + __len - 40);
+ _Size __y = std::__loadword<_Size>(__s + __len - 16) +
+ std::__loadword<_Size>(__s + __len - 56);
+ _Size __z = __hash_len_16(std::__loadword<_Size>(__s + __len - 48) + __len,
+ std::__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);
+ __x = __x * __k1 + std::__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 = __rotate(__x + __y + __v.first + std::__loadword<_Size>(__s + 8), 37) * __k1;
+ __y = __rotate(__y + __v.second + std::__loadword<_Size>(__s + 48), 42) * __k1;
__x ^= __w.second;
- __y += __v.first + __loadword<_Size>(__s + 40);
+ __y += __v.first + std::__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));
+ __y + std::__loadword<_Size>(__s + 16));
_VSTD::swap(__z, __x);
__s += 64;
__len -= 64;
diff --git a/libcxx/include/__functional/invoke.h b/libcxx/include/__functional/invoke.h
index d56a0accdbce..48e6eac3ce98 100644
--- a/libcxx/include/__functional/invoke.h
+++ b/libcxx/include/__functional/invoke.h
@@ -248,7 +248,7 @@ struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
template <class _MP>
struct __member_pointer_traits
- : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
+ : public __member_pointer_traits_imp<__remove_cv_t<_MP>,
is_member_function_pointer<_MP>::value,
is_member_object_pointer<_MP>::value>
{
@@ -398,7 +398,7 @@ template <class _Ret, class _Fp, class ..._Args>
struct __invokable_r
{
template <class _XFp, class ..._XArgs>
- static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
+ static decltype(std::__invoke(std::declval<_XFp>(), std::declval<_XArgs>()...)) __try_call(int);
template <class _XFp, class ..._XArgs>
static __nat __try_call(...);
@@ -406,10 +406,10 @@ struct __invokable_r
// or incomplete array types as required by the standard.
using _Result = decltype(__try_call<_Fp, _Args...>(0));
- using type = typename conditional<
+ using type = __conditional_t<
_IsNotSame<_Result, __nat>::value,
- typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,
- false_type >::type;
+ __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
+ false_type>;
static const bool value = type::value;
};
template <class _Fp, class ..._Args>
@@ -428,15 +428,23 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
template <class _Tp>
static void __test_noexcept(_Tp) _NOEXCEPT;
+#ifdef _LIBCPP_CXX03_LANG
+ static const bool value = false;
+#else
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
- _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
+ _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)));
+#endif
};
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
+#ifdef _LIBCPP_CXX03_LANG
+ static const bool value = false;
+#else
static const bool value = noexcept(
- _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
+ _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));
+#endif
};
template <class _Ret, class _Fp, class ..._Args>
@@ -524,7 +532,7 @@ template <class _Fn, class... _Args>
using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
template <class _Fn, class ..._Args>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 invoke_result_t<_Fn, _Args...>
invoke(_Fn&& __f, _Args&&... __args)
noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
{
diff --git a/libcxx/include/__functional/is_transparent.h b/libcxx/include/__functional/is_transparent.h
index 74326c76c12f..c7a0ee9ee7b8 100644
--- a/libcxx/include/__functional/is_transparent.h
+++ b/libcxx/include/__functional/is_transparent.h
@@ -25,8 +25,7 @@ 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>
+struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> >
: true_type {};
#endif
diff --git a/libcxx/include/__functional/mem_fn.h b/libcxx/include/__functional/mem_fn.h
index a5818b3f018c..8b51627079cf 100644
--- a/libcxx/include/__functional/mem_fn.h
+++ b/libcxx/include/__functional/mem_fn.h
@@ -33,12 +33,12 @@ private:
type __f_;
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
// invoke
template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
@@ -47,7 +47,7 @@ public:
};
template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__mem_fn<_Rp _Tp::*>
mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
{
diff --git a/libcxx/include/__functional/not_fn.h b/libcxx/include/__functional/not_fn.h
index b5c415c25c44..79d9a8710bd0 100644
--- a/libcxx/include/__functional/not_fn.h
+++ b/libcxx/include/__functional/not_fn.h
@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
struct __not_fn_op {
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI
- _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 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)...); }
@@ -43,7 +43,7 @@ template <class _Fn, class = enable_if_t<
is_move_constructible_v<decay_t<_Fn>>
>>
_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) {
+_LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));
}
diff --git a/libcxx/include/__functional/operations.h b/libcxx/include/__functional/operations.h
index 1c73c999db91..8a781efbdbbb 100644
--- a/libcxx/include/__functional/operations.h
+++ b/libcxx/include/__functional/operations.h
@@ -32,17 +32,18 @@ struct _LIBCPP_TEMPLATE_VIS plus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x + __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS plus<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -60,17 +61,18 @@ struct _LIBCPP_TEMPLATE_VIS minus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x - __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS minus<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -88,17 +90,18 @@ struct _LIBCPP_TEMPLATE_VIS multiplies
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x * __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS multiplies<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -116,17 +119,18 @@ struct _LIBCPP_TEMPLATE_VIS divides
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x / __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS divides<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -144,17 +148,18 @@ struct _LIBCPP_TEMPLATE_VIS modulus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x % __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS modulus<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -172,17 +177,18 @@ struct _LIBCPP_TEMPLATE_VIS negate
: __unary_function<_Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return -__x;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS negate<void>
{
template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
-> decltype( - _VSTD::forward<_Tp>(__x))
@@ -202,17 +208,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_and
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x & __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -226,16 +233,17 @@ template <class _Tp = void>
struct _LIBCPP_TEMPLATE_VIS bit_not
: __unary_function<_Tp, _Tp>
{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return ~__x;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
template <>
struct _LIBCPP_TEMPLATE_VIS bit_not<void>
{
template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
-> decltype( ~_VSTD::forward<_Tp>(__x))
@@ -253,17 +261,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_or
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x | __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -281,17 +290,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x ^ __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -311,17 +321,18 @@ struct _LIBCPP_TEMPLATE_VIS equal_to
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x == __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -339,17 +350,18 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x != __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -367,17 +379,18 @@ struct _LIBCPP_TEMPLATE_VIS less
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x < __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS less<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -395,17 +408,18 @@ struct _LIBCPP_TEMPLATE_VIS less_equal
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x <= __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -423,17 +437,18 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x >= __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -451,17 +466,18 @@ struct _LIBCPP_TEMPLATE_VIS greater
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x > __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS greater<void>
{
template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -481,17 +497,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_and
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x && __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
@@ -509,17 +526,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_not
: __unary_function<_Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x) const
{return !__x;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TEMPLATE_VIS logical_not<void>
{
template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
-> decltype( !_VSTD::forward<_Tp>(__x))
@@ -537,17 +555,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_or
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x || __y;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
#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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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))
diff --git a/libcxx/include/__functional/ranges_operations.h b/libcxx/include/__functional/ranges_operations.h
index 3f63a86731e0..87081dd56a05 100644
--- a/libcxx/include/__functional/ranges_operations.h
+++ b/libcxx/include/__functional/ranges_operations.h
@@ -10,9 +10,10 @@
#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
+#include <__concepts/equality_comparable.h>
+#include <__concepts/totally_ordered.h>
#include <__config>
#include <__utility/forward.h>
-#include <concepts>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h
index 8245e3a04734..c377b6437701 100644
--- a/libcxx/include/__functional/reference_wrapper.h
+++ b/libcxx/include/__functional/reference_wrapper.h
@@ -11,10 +11,13 @@
#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
#include <__config>
+#include <__functional/invoke.h>
#include <__functional/weak_result_type.h>
#include <__memory/addressof.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -35,22 +38,22 @@ private:
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>()))) {
+ template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+ reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
type& __f = static_cast<_Up&&>(__u);
__f_ = _VSTD::addressof(__f);
}
// access
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
operator type&() const _NOEXCEPT {return *__f_;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
type& get() const _NOEXCEPT {return *__f_;}
// invoke
template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __invoke_of<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
@@ -63,7 +66,7 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
#endif
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<_Tp>
ref(_Tp& __t) _NOEXCEPT
{
@@ -71,7 +74,7 @@ ref(_Tp& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
@@ -79,7 +82,7 @@ ref(reference_wrapper<_Tp> __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<const _Tp>
cref(const _Tp& __t) _NOEXCEPT
{
@@ -87,7 +90,7 @@ cref(const _Tp& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
diff --git a/libcxx/include/__functional/unary_negate.h b/libcxx/include/__functional/unary_negate.h
index 7f081903fe44..ab87e86d189f 100644
--- a/libcxx/include/__functional/unary_negate.h
+++ b/libcxx/include/__functional/unary_negate.h
@@ -27,16 +27,16 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
{
_Predicate __pred_;
public:
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
explicit unary_negate(const _Predicate& __pred)
: __pred_(__pred) {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
unary_negate<_Predicate>
not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
diff --git a/libcxx/include/__functional/unwrap_ref.h b/libcxx/include/__functional/unwrap_ref.h
index f7207934e1b4..da000d80b8c9 100644
--- a/libcxx/include/__functional/unwrap_ref.h
+++ b/libcxx/include/__functional/unwrap_ref.h
@@ -10,6 +10,7 @@
#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
#include <__config>
+#include <__type_traits/decay.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h
index 96d8cf7146b1..18d1bf718c4e 100644
--- a/libcxx/include/__functional/weak_result_type.h
+++ b/libcxx/include/__functional/weak_result_type.h
@@ -12,8 +12,11 @@
#include <__config>
#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
#include <__functional/unary_function.h>
-#include <type_traits>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -283,7 +286,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
template <class _Tp, class ..._Args>
struct __invoke_return
{
- typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
+ typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h
new file mode 100644
index 000000000000..9a79effb617d
--- /dev/null
+++ b/libcxx/include/__fwd/array.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___FWD_ARRAY_H
+#define _LIBCPP___FWD_ARRAY_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 _Size>
+struct _LIBCPP_TEMPLATE_VIS array;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_ARRAY_H
diff --git a/libcxx/include/__fwd/get.h b/libcxx/include/__fwd/get.h
new file mode 100644
index 000000000000..ec1fab4602d7
--- /dev/null
+++ b/libcxx/include/__fwd/get.h
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FWD_GET_H
+#define _LIBCPP___FWD_GET_H
+
+#include <__concepts/copyable.h>
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/pair.h>
+#include <__fwd/subrange.h>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/tuple_element.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(const tuple<_Tp...>&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&&) _NOEXCEPT;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(const tuple<_Tp...>&&) _NOEXCEPT;
+
+#endif //_LIBCPP_CXX03_LANG
+
+template <size_t _Ip, class _T1, class _T2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+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_SINCE_CXX14
+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_SINCE_CXX14
+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_SINCE_CXX14
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&&) _NOEXCEPT;
+#endif
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_Tp&
+get(array<_Tp, _Size>&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+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_SINCE_CXX14
+_Tp&&
+get(array<_Tp, _Size>&&) _NOEXCEPT;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+const _Tp&&
+get(const array<_Tp, _Size>&&) _NOEXCEPT;
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+namespace ranges {
+
+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);
+
+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);
+
+} // namespace ranges
+
+using ranges::get;
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_GET_H
diff --git a/libcxx/include/__fwd/hash.h b/libcxx/include/__fwd/hash.h
new file mode 100644
index 000000000000..af9eca876a10
--- /dev/null
+++ b/libcxx/include/__fwd/hash.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___FWD_HASH_H
+#define _LIBCPP___FWD_HASH_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class>
+struct _LIBCPP_TEMPLATE_VIS hash;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_HASH_H
diff --git a/libcxx/include/__fwd/memory_resource.h b/libcxx/include/__fwd/memory_resource.h
new file mode 100644
index 000000000000..718a9078d3cf
--- /dev/null
+++ b/libcxx/include/__fwd/memory_resource.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___FWD_MEMORY_RESOURCE_H
+#define _LIBCPP___FWD_MEMORY_RESOURCE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+template <class _ValueType>
+class _LIBCPP_TEMPLATE_VIS polymorphic_allocator;
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_MEMORY_RESOURCE_H
diff --git a/libcxx/include/__fwd/pair.h b/libcxx/include/__fwd/pair.h
new file mode 100644
index 000000000000..3844014de3ad
--- /dev/null
+++ b/libcxx/include/__fwd/pair.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___FWD_PAIR_H
+#define _LIBCPP___FWD_PAIR_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class, class>
+struct _LIBCPP_TEMPLATE_VIS pair;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_PAIR_H
diff --git a/libcxx/include/__fwd/span.h b/libcxx/include/__fwd/span.h
index f38b8cfa0526..943cb13fa1bb 100644
--- a/libcxx/include/__fwd/span.h
+++ b/libcxx/include/__fwd/span.h
@@ -7,8 +7,8 @@
//
//===---------------------------------------------------------------------===//
-#ifndef _LIBCPP_FWD_SPAN_H
-#define _LIBCPP_FWD_SPAN_H
+#ifndef _LIBCPP___FWD_SPAN_H
+#define _LIBCPP___FWD_SPAN_H
#include <__config>
#include <cstddef>
@@ -34,4 +34,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_FWD_SPAN_H
+#endif // _LIBCPP___FWD_SPAN_H
diff --git a/libcxx/include/__fwd/string.h b/libcxx/include/__fwd/string.h
new file mode 100644
index 000000000000..7ab5561b758f
--- /dev/null
+++ b/libcxx/include/__fwd/string.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___FWD_STRING_H
+#define _LIBCPP___FWD_STRING_H
+
+#include <__config>
+#include <__fwd/memory_resource.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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 _Allocator = allocator<_CharT> >
+class _LIBCPP_TEMPLATE_VIS basic_string;
+
+using string = basic_string<char>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wstring = basic_string<wchar_t>;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+using u8string = basic_string<char8_t>;
+#endif
+
+using u16string = basic_string<char16_t>;
+using u32string = basic_string<char32_t>;
+
+#if _LIBCPP_STD_VER >= 17
+
+namespace pmr {
+template <class _CharT, class _Traits = char_traits<_CharT>>
+using basic_string = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
+
+using string = basic_string<char>;
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wstring = basic_string<wchar_t>;
+# endif
+
+# ifndef _LIBCPP_HAS_NO_CHAR8_T
+using u8string = basic_string<char8_t>;
+# endif
+
+using u16string = basic_string<char16_t>;
+using u32string = basic_string<char32_t>;
+
+} // namespace pmr
+
+#endif // _LIBCPP_STD_VER >= 17
+
+// clang-format off
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_PREFERRED_NAME(string)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_PREFERRED_NAME(wstring)
+#endif
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string)
+#endif
+ _LIBCPP_PREFERRED_NAME(u16string)
+ _LIBCPP_PREFERRED_NAME(u32string)
+#if _LIBCPP_STD_VER >= 17
+ _LIBCPP_PREFERRED_NAME(pmr::string)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_PREFERRED_NAME(pmr::wstring)
+# endif
+# ifndef _LIBCPP_HAS_NO_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(pmr::u8string)
+# endif
+ _LIBCPP_PREFERRED_NAME(pmr::u16string)
+ _LIBCPP_PREFERRED_NAME(pmr::u32string)
+#endif
+ basic_string;
+// clang-format on
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_STRING_H
diff --git a/libcxx/include/__fwd/string_view.h b/libcxx/include/__fwd/string_view.h
index e5e77b292a6e..4818990248da 100644
--- a/libcxx/include/__fwd/string_view.h
+++ b/libcxx/include/__fwd/string_view.h
@@ -7,8 +7,8 @@
//
//===---------------------------------------------------------------------===//
-#ifndef _LIBCPP_FWD_STRING_VIEW_H
-#define _LIBCPP_FWD_STRING_VIEW_H
+#ifndef _LIBCPP___FWD_STRING_VIEW_H
+#define _LIBCPP___FWD_STRING_VIEW_H
#include <__config>
#include <iosfwd> // char_traits
@@ -32,6 +32,19 @@ typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
#endif
+// clang-format off
+template <class _CharT, class _Traits>
+class _LIBCPP_PREFERRED_NAME(string_view)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ _LIBCPP_PREFERRED_NAME(wstring_view)
+#endif
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ _LIBCPP_PREFERRED_NAME(u8string_view)
+#endif
+ _LIBCPP_PREFERRED_NAME(u16string_view)
+ _LIBCPP_PREFERRED_NAME(u32string_view)
+ basic_string_view;
+// clang-format on
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_FWD_STRING_VIEW_H
+#endif // _LIBCPP___FWD_STRING_VIEW_H
diff --git a/libcxx/include/__fwd/subrange.h b/libcxx/include/__fwd/subrange.h
new file mode 100644
index 000000000000..8f7239247eff
--- /dev/null
+++ b/libcxx/include/__fwd/subrange.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___FWD_SUBRANGE_H
+#define _LIBCPP___FWD_SUBRANGE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+#include <__iterator/concepts.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized };
+
+template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind>
+ requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
+class _LIBCPP_TEMPLATE_VIS subrange;
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP___FWD_SUBRANGE_H
diff --git a/libcxx/include/__fwd/tuple.h b/libcxx/include/__fwd/tuple.h
new file mode 100644
index 000000000000..16b3fabbb995
--- /dev/null
+++ b/libcxx/include/__fwd/tuple.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___FWD_TUPLE_H
+#define _LIBCPP___FWD_TUPLE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class...>
+class _LIBCPP_TEMPLATE_VIS tuple;
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FWD_TUPLE_H
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 959ef7fe7d83..f8896c8664eb 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -13,16 +13,25 @@
#include <__algorithm/max.h>
#include <__algorithm/min.h>
#include <__assert>
-#include <__bits> // __libcpp_clz
+#include <__bit/countl.h>
#include <__config>
#include <__debug>
#include <__functional/hash.h>
#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/can_extract_key.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#include <__utility/swap.h>
#include <cmath>
+#include <cstring>
#include <initializer_list>
-#include <memory>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -48,7 +57,7 @@ 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> > {};
+struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__remove_cvref_t<_One> > {};
_LIBCPP_FUNC_VIS
size_t __next_prime(size_t __n);
@@ -58,16 +67,13 @@ 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 __rebind_pointer_t<_NodePtr, __first_node> __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;
+ typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer;
#endif
__next_pointer __next_;
@@ -96,7 +102,7 @@ template <class _Tp, class _VoidPtr>
struct _LIBCPP_STANDALONE_DEBUG __hash_node
: public __hash_node_base
<
- typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
+ __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> >
>
{
typedef _Tp __node_value_type;
@@ -208,9 +214,9 @@ 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
+ typedef __rebind_pointer_t<_AllocPtr, _Mv>
__map_value_type_pointer;
- typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+ typedef __rebind_pointer_t<_AllocPtr, const _Mv>
__const_map_value_type_pointer;
};
@@ -228,21 +234,21 @@ public:
typedef ptrdiff_t difference_type;
typedef size_t size_type;
- typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
+ typedef __rebind_pointer_t<_NodePtr, void> __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
+ typedef __rebind_pointer_t<_NodePtr, __node_base_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
+ typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
__node_value_type_pointer;
- typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+ typedef __rebind_pointer_t<_VoidPtr, const __node_value_type>
__const_node_value_type_pointer;
private:
@@ -250,7 +256,7 @@ private:
"_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,
+ static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>,
_NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
};
@@ -269,7 +275,7 @@ struct __hash_node_types_from_iterator<__hash_const_local_iterator<_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 __rebind_pointer_t<_VoidPtr, _NodeTp> _NodePtr;
typedef __hash_node_types<_NodePtr> type;
};
@@ -559,7 +565,7 @@ public:
_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_)
+ if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
__node_ = nullptr;
return *this;
}
@@ -614,8 +620,8 @@ class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator
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
+ typedef __remove_const_t<__node> __non_const_node;
+ typedef __rebind_pointer_t<__node_pointer, __non_const_node>
__non_const_node_pointer;
public:
typedef __hash_local_iterator<__non_const_node_pointer>
@@ -692,7 +698,7 @@ public:
_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_)
+ if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
__node_ = nullptr;
return *this;
}
@@ -892,7 +898,7 @@ public:
// Create __node
typedef typename _NodeTypes::__node_type __node;
- typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
+ typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename _NodeTypes::__void_pointer __void_pointer;
typedef typename _NodeTypes::__node_pointer __node_pointer;
@@ -907,15 +913,14 @@ private:
// 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 __rebind_alloc<__node_traits, __first_node> __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 __rebind_alloc<__node_traits, __next_pointer> __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;
@@ -1151,11 +1156,11 @@ public:
_LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
_LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
{
- __rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor())));
+ __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor())));
}
_LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
{
- __rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor())));
+ __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor())));
}
_LIBCPP_INLINE_VISIBILITY
@@ -1179,7 +1184,7 @@ public:
{
_LIBCPP_ASSERT(bucket_count() > 0,
"unordered container::bucket(key) called when bucket_count() == 0");
- return __constrain_hash(hash_function()(__k), bucket_count());
+ return std::__constrain_hash(hash_function()(__k), bucket_count());
}
template <class _Key>
@@ -1428,7 +1433,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
{
if (size() > 0)
{
- __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
__p1_.first().__ptr();
__u.__p1_.first().__next_ = nullptr;
__u.size() = 0;
@@ -1452,7 +1457,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
{
__p1_.first().__next_ = __u.__p1_.first().__next_;
__u.__p1_.first().__next_ = nullptr;
- __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
__p1_.first().__ptr();
size() = __u.size();
__u.size() = 0;
@@ -1569,7 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
__p1_.first().__next_ = __u.__p1_.first().__next_;
if (size() > 0)
{
- __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
__p1_.first().__ptr();
__u.__p1_.first().__next_ = nullptr;
__u.size() = 0;
@@ -1784,12 +1789,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
if (__bc != 0)
{
- size_t __chash = __constrain_hash(__hash, __bc);
+ size_t __chash = std::__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;
+ std::__constrain_hash(__ndptr->__hash(), __bc) == __chash;
__ndptr = __ndptr->__next_)
{
if (key_eq()(__ndptr->__upcast()->__value_, __value))
@@ -1799,8 +1804,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
}
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
- size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
+ size_type(std::ceil(float(size() + 1) / max_load_factor()))));
}
return nullptr;
}
@@ -1816,7 +1821,7 @@ __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);
+ size_t __chash = std::__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)
@@ -1827,7 +1832,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
// fix up __bucket_list_
__bucket_list_[__chash] = __pn;
if (__nd->__next_ != nullptr)
- __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
+ __bucket_list_[std::__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
}
else
{
@@ -1871,16 +1876,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
- size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
+ size_type(std::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
- size_t __chash = __constrain_hash(__cp_hash, __bc);
+ size_t __chash = std::__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;
+ std::__constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
__pn = __pn->__next_)
{
// __found key_eq() action
@@ -1912,7 +1917,7 @@ __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);
+ size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
if (__pn == nullptr)
{
__pn =__p1_.first().__ptr();
@@ -1921,7 +1926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
// fix up __bucket_list_
__bucket_list_[__chash] = __pn;
if (__cp->__next_ != nullptr)
- __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)]
+ __bucket_list_[std::__constrain_hash(__cp->__next_->__hash(), __bc)]
= __cp->__ptr();
}
else
@@ -1930,7 +1935,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
__pn->__next_ = __cp->__ptr();
if (__cp->__next_ != nullptr)
{
- size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc);
+ size_t __nhash = std::__constrain_hash(__cp->__next_->__hash(), __bc);
if (__nhash != __chash)
__bucket_list_[__nhash] = __cp->__ptr();
}
@@ -1965,11 +1970,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
- size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
+ size_type(std::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
- size_t __chash = __constrain_hash(__cp->__hash_, __bc);
+ size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
__next_pointer __pp = __bucket_list_[__chash];
while (__pp->__next_ != __np)
__pp = __pp->__next_;
@@ -1996,12 +2001,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
size_t __chash;
if (__bc != 0)
{
- __chash = __constrain_hash(__hash, __bc);
+ __chash = std::__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->__hash() == __hash || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
__nd = __nd->__next_)
{
if (key_eq()(__nd->__upcast()->__value_, __k))
@@ -2013,10 +2018,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
__node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
- __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
- size_type(ceil(float(size() + 1) / max_load_factor()))));
+ __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
+ size_type(std::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
- __chash = __constrain_hash(__hash, __bc);
+ __chash = std::__constrain_hash(__hash, __bc);
}
// insert_after __bucket_list_[__chash], or __first_node if bucket is null
__next_pointer __pn = __bucket_list_[__chash];
@@ -2028,7 +2033,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
// fix up __bucket_list_
__bucket_list_[__chash] = __pn;
if (__h->__next_ != nullptr)
- __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)]
+ __bucket_list_[std::__constrain_hash(__h->__next_->__hash(), __bc)]
= __h.get()->__ptr();
}
else
@@ -2224,7 +2229,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
if (__n == 1)
__n = 2;
else if (__n & (__n - 1))
- __n = __next_prime(__n);
+ __n = std::__next_prime(__n);
size_type __bc = bucket_count();
if (__n > __bc)
__do_rehash<_UniqueKeys>(__n);
@@ -2233,8 +2238,8 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
__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())))
+ std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) :
+ std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))
);
if (__n < __bc)
__do_rehash<_UniqueKeys>(__n);
@@ -2259,13 +2264,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
__next_pointer __cp = __pp->__next_;
if (__cp != nullptr)
{
- size_type __chash = __constrain_hash(__cp->__hash(), __nbc);
+ size_type __chash = std::__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);
+ __chash = std::__constrain_hash(__cp->__hash(), __nbc);
if (__chash == __phash)
__pp = __cp;
else
@@ -2279,7 +2284,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
else
{
__next_pointer __np = __cp;
- if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)
+ if _LIBCPP_CONSTEXPR_SINCE_CXX17 (!_UniqueKeys)
{
for (; __np->__next_ != nullptr &&
key_eq()(__cp->__upcast()->__value_,
@@ -2307,13 +2312,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
size_type __bc = bucket_count();
if (__bc != 0)
{
- size_t __chash = __constrain_hash(__hash, __bc);
+ size_t __chash = std::__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);
+ || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
__nd = __nd->__next_)
{
if ((__nd->__hash() == __hash)
@@ -2334,13 +2339,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
size_type __bc = bucket_count();
if (__bc != 0)
{
- size_t __chash = __constrain_hash(__hash, __bc);
+ size_t __chash = std::__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);
+ || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
__nd = __nd->__next_)
{
if ((__nd->__hash() == __hash)
@@ -2462,7 +2467,7 @@ __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);
+ size_t __chash = std::__constrain_hash(__cn->__hash(), __bc);
// find previous node
__next_pointer __pn = __bucket_list_[__chash];
for (; __pn->__next_ != __cn; __pn = __pn->__next_)
@@ -2471,16 +2476,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
// 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)
+ || std::__constrain_hash(__pn->__hash(), __bc) != __chash)
{
if (__cn->__next_ == nullptr
- || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
+ || std::__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);
+ size_t __nhash = std::__constrain_hash(__cn->__next_->__hash(), __bc);
if (__nhash != __chash)
__bucket_list_[__nhash] = __pn;
}
@@ -2634,10 +2639,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
__p2_.swap(__u.__p2_);
__p3_.swap(__u.__p3_);
if (size() > 0)
- __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
+ __bucket_list_[std::__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.__bucket_list_[std::__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
__u.__p1_.first().__ptr();
std::__debug_db_swap(this, std::addressof(__u));
}
@@ -2654,8 +2659,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
if (__np != nullptr)
{
for (__np = __np->__next_; __np != nullptr &&
- __constrain_hash(__np->__hash(), __bc) == __n;
- __np = __np->__next_, (void) ++__r)
+ std::__constrain_hash(__np->__hash(), __bc) == __n;
+ __np = __np->__next_, (void) ++__r)
;
}
return __r;
diff --git a/libcxx/include/__iterator/access.h b/libcxx/include/__iterator/access.h
index 7abd4c5573d6..0b8d5230171b 100644
--- a/libcxx/include/__iterator/access.h
+++ b/libcxx/include/__iterator/access.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp*
begin(_Tp (&__array)[_Np])
{
@@ -28,7 +28,7 @@ begin(_Tp (&__array)[_Np])
}
template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp*
end(_Tp (&__array)[_Np])
{
@@ -38,7 +38,7 @@ end(_Tp (&__array)[_Np])
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto
begin(_Cp& __c) -> decltype(__c.begin())
{
@@ -46,7 +46,7 @@ begin(_Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto
begin(const _Cp& __c) -> decltype(__c.begin())
{
@@ -54,7 +54,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto
end(_Cp& __c) -> decltype(__c.end())
{
@@ -62,7 +62,7 @@ end(_Cp& __c) -> decltype(__c.end())
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto
end(const _Cp& __c) -> decltype(__c.end())
{
@@ -72,14 +72,14 @@ end(const _Cp& __c) -> decltype(__c.end())
#if _LIBCPP_STD_VER > 11
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
{
return _VSTD::begin(__c);
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
{
return _VSTD::end(__c);
diff --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h
index 4b8b0dc970a1..154c2736f313 100644
--- a/libcxx/include/__iterator/advance.h
+++ b/libcxx/include/__iterator/advance.h
@@ -11,16 +11,20 @@
#define _LIBCPP___ITERATOR_ADVANCE_H
#include <__assert>
+#include <__concepts/assignable.h>
+#include <__concepts/same_as.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_integral.h>
+#include <__utility/convert_to_integral.h>
+#include <__utility/declval.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
@@ -29,14 +33,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) {
if (__n >= 0)
for (; __n > 0; --__n)
@@ -47,16 +51,16 @@ void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference
}
template <class _RandIter>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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 _IntegralDistance = decltype(_VSTD::__convert_to_integral(std::declval<_Distance>())),
class = __enable_if_t<is_integral<_IntegralDistance>::value> >
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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));
@@ -65,7 +69,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
_VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.iter.op.advance]
@@ -192,7 +196,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/back_insert_iterator.h b/libcxx/include/__iterator/back_insert_iterator.h
index e9f9f2abec2a..4c00a7e39796 100644
--- a/libcxx/include/__iterator/back_insert_iterator.h
+++ b/libcxx/include/__iterator/back_insert_iterator.h
@@ -45,22 +45,23 @@ public:
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)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() {return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator++() {return *this;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator operator++(int) {return *this;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Container* __get_container() const { return container; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Container* __get_container() const { return container; }
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator);
template <class _Container>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
back_insert_iterator<_Container>
back_inserter(_Container& __x)
{
diff --git a/libcxx/include/__iterator/bounded_iter.h b/libcxx/include/__iterator/bounded_iter.h
index a395e2b638eb..2682f2a68a22 100644
--- a/libcxx/include/__iterator/bounded_iter.h
+++ b/libcxx/include/__iterator/bounded_iter.h
@@ -14,8 +14,10 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_convertible.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -73,7 +75,7 @@ private:
//
// Since it is non-standard for iterators to have this constructor, __bounded_iter must
// be created via `std::__make_bounded_iter`.
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __bounded_iter(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter(
_Iterator __current, _Iterator __begin, _Iterator __end)
: __current_(__current), __begin_(__begin), __end_(__end) {
_LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
@@ -86,19 +88,19 @@ public:
// Dereference and indexing operations.
//
// These operations check that the iterator is dereferenceable, that is within [begin, end).
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
_LIBCPP_ASSERT(
__in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
return *__current_;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
_LIBCPP_ASSERT(
__in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
return std::__to_address(__current_);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
_LIBCPP_ASSERT(
__in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
return __current_[__n];
@@ -108,54 +110,54 @@ public:
//
// These operations do not check that the resulting iterator is within the bounds, since that
// would make it impossible to create a past-the-end iterator.
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator++() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator++() _NOEXCEPT {
++__current_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator++(int) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter operator++(int) _NOEXCEPT {
__bounded_iter __tmp(*this);
++*this;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator--() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator--() _NOEXCEPT {
--__current_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator--(int) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter operator--(int) _NOEXCEPT {
__bounded_iter __tmp(*this);
--*this;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
__current_ += __n;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
__bounded_iter __tmp(__self);
__tmp += __n;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
__bounded_iter __tmp(__self);
__tmp += __n;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
__current_ -= __n;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
__bounded_iter __tmp(__self);
__tmp -= __n;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
return __x.__current_ - __y.__current_;
}
diff --git a/libcxx/include/__iterator/common_iterator.h b/libcxx/include/__iterator/common_iterator.h
index abcc0b675e63..f7883e2c372f 100644
--- a/libcxx/include/__iterator/common_iterator.h
+++ b/libcxx/include/__iterator/common_iterator.h
@@ -11,6 +11,13 @@
#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
#include <__assert>
+#include <__concepts/assignable.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/same_as.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -18,7 +25,8 @@
#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/readable_traits.h>
-#include <concepts>
+#include <__type_traits/is_pointer.h>
+#include <__utility/declval.h>
#include <variant>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -95,14 +103,14 @@ public:
constexpr decltype(auto) operator*()
{
- _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
+ _LIBCPP_ASSERT(std::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");
+ _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
return *_VSTD::__unchecked_get<_Iter>(__hold_);
}
@@ -113,7 +121,7 @@ public:
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");
+ _LIBCPP_ASSERT(std::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>>) {
@@ -125,12 +133,12 @@ public:
}
common_iterator& operator++() {
- _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
+ _LIBCPP_ASSERT(std::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");
+ _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
if constexpr (forward_iterator<_Iter>) {
auto __tmp = *this;
++*this;
@@ -147,6 +155,7 @@ public:
template<class _I2, sentinel_for<_Iter> _S2>
requires sentinel_for<_Sent, _I2>
+ _LIBCPP_HIDE_FROM_ABI
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");
@@ -165,6 +174,7 @@ public:
template<class _I2, sentinel_for<_Iter> _S2>
requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
+ _LIBCPP_HIDE_FROM_ABI
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");
@@ -186,6 +196,7 @@ public:
template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2>
requires sized_sentinel_for<_Sent, _I2>
+ _LIBCPP_HIDE_FROM_ABI
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");
@@ -205,20 +216,20 @@ public:
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&>())))
+ _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
+ noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
requires input_iterator<_Iter>
{
- _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
+ _LIBCPP_ASSERT(std::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_HIDE_FROM_ABI friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)
+ noexcept(noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::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");
+ _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
+ _LIBCPP_ASSERT(std::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_));
}
};
@@ -246,7 +257,7 @@ struct __arrow_type_or_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->());
+ using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
};
template<input_iterator _Iter, class _Sent>
diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h
index bd68889333ce..d9d40a4249f4 100644
--- a/libcxx/include/__iterator/concepts.h
+++ b/libcxx/include/__iterator/concepts.h
@@ -10,15 +10,35 @@
#ifndef _LIBCPP___ITERATOR_CONCEPTS_H
#define _LIBCPP___ITERATOR_CONCEPTS_H
+#include <__concepts/arithmetic.h>
+#include <__concepts/assignable.h>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_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/totally_ordered.h>
#include <__config>
+#include <__functional/invoke.h>
#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 <__type_traits/add_pointer.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
-#include <concepts>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/counted_iterator.h b/libcxx/include/__iterator/counted_iterator.h
index b0f5c66ecf21..5fdbff4b4866 100644
--- a/libcxx/include/__iterator/counted_iterator.h
+++ b/libcxx/include/__iterator/counted_iterator.h
@@ -6,10 +6,16 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
#include <__assert>
+#include <__concepts/assignable.h>
+#include <__concepts/common_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/same_as.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/default_sentinel.h>
@@ -19,10 +25,10 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/readable_traits.h>
#include <__memory/pointer_traits.h>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/conditional.h>
#include <__utility/move.h>
#include <compare>
-#include <concepts>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -263,7 +269,7 @@ public:
}
template<common_with<_Iter> _I2>
- friend constexpr strong_ordering operator<=>(
+ _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(
const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
{
return __rhs.__count_ <=> __lhs.__count_;
@@ -288,6 +294,7 @@ public:
return ranges::iter_swap(__x.__current_, __y.__current_);
}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(counted_iterator);
template<input_iterator _Iter>
requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>>
diff --git a/libcxx/include/__iterator/distance.h b/libcxx/include/__iterator/distance.h
index 8819078958d3..681e20d045b7 100644
--- a/libcxx/include/__iterator/distance.h
+++ b/libcxx/include/__iterator/distance.h
@@ -17,7 +17,8 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/size.h>
-#include <type_traits>
+#include <__type_traits/decay.h>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -26,7 +27,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
typename iterator_traits<_InputIter>::difference_type
__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
{
@@ -37,7 +38,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
}
template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
typename iterator_traits<_RandIter>::difference_type
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
{
@@ -45,14 +46,14 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.iter.op.distance]
@@ -75,7 +76,7 @@ struct __fn {
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>>) {
+ if constexpr (sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>) {
return __last - __first;
} else {
return __last - decay_t<_Ip>(__first);
@@ -100,7 +101,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/front_insert_iterator.h b/libcxx/include/__iterator/front_insert_iterator.h
index 9c8ec0028298..e278359d870d 100644
--- a/libcxx/include/__iterator/front_insert_iterator.h
+++ b/libcxx/include/__iterator/front_insert_iterator.h
@@ -45,20 +45,21 @@ public:
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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator operator++(int) {return *this;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(front_insert_iterator);
template <class _Container>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
front_insert_iterator<_Container>
front_inserter(_Container& __x)
{
diff --git a/libcxx/include/__iterator/incrementable_traits.h b/libcxx/include/__iterator/incrementable_traits.h
index 4109b58d46a9..3d06dc05359b 100644
--- a/libcxx/include/__iterator/incrementable_traits.h
+++ b/libcxx/include/__iterator/incrementable_traits.h
@@ -10,10 +10,15 @@
#ifndef _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
+#include <__concepts/arithmetic.h>
#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_object.h>
#include <__type_traits/is_primary_template.h>
-#include <concepts>
-#include <type_traits>
+#include <__type_traits/make_signed.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -52,7 +57,7 @@ concept __has_integral_minus =
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>())>;
+ using difference_type = make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
};
template <class>
diff --git a/libcxx/include/__iterator/insert_iterator.h b/libcxx/include/__iterator/insert_iterator.h
index b35d8bf16af9..ecaea61c61e7 100644
--- a/libcxx/include/__iterator/insert_iterator.h
+++ b/libcxx/include/__iterator/insert_iterator.h
@@ -24,7 +24,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
template <class _Container>
using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
#else
@@ -55,21 +55,21 @@ public:
typedef void reference;
typedef _Container container_type;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++(int) {return *this;}
};
template <class _Container>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
insert_iterator<_Container>
inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i)
{
diff --git a/libcxx/include/__iterator/iter_move.h b/libcxx/include/__iterator/iter_move.h
index d8240ab9c2f1..a7d9413fb84b 100644
--- a/libcxx/include/__iterator/iter_move.h
+++ b/libcxx/include/__iterator/iter_move.h
@@ -13,9 +13,11 @@
#include <__concepts/class_or_enum.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,6 +38,7 @@ template <class _Tp>
concept __unqualified_iter_move =
__class_or_enum<remove_cvref_t<_Tp>> &&
requires (_Tp&& __t) {
+ // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
iter_move(std::forward<_Tp>(__t));
};
@@ -59,6 +62,7 @@ concept __just_deref =
// [iterator.cust.move]
struct __fn {
+ // NOLINTBEGIN(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move
template<class _Ip>
requires __unqualified_iter_move<_Ip>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
@@ -66,6 +70,7 @@ struct __fn {
{
return iter_move(std::forward<_Ip>(__i));
}
+ // NOLINTEND(libcpp-robust-against-adl)
template<class _Ip>
requires __move_deref<_Ip>
@@ -90,7 +95,7 @@ inline namespace __cpo {
template<__dereferenceable _Tp>
requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
-using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
+using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
#endif // _LIBCPP_STD_VER > 17
diff --git a/libcxx/include/__iterator/iter_swap.h b/libcxx/include/__iterator/iter_swap.h
index 9e06464c3690..d4c0dca1f63d 100644
--- a/libcxx/include/__iterator/iter_swap.h
+++ b/libcxx/include/__iterator/iter_swap.h
@@ -6,18 +6,21 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___ITERATOR_ITER_SWAP_H
#define _LIBCPP___ITERATOR_ITER_SWAP_H
+#include <__concepts/class_or_enum.h>
+#include <__concepts/swappable.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iter_move.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/readable_traits.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.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
@@ -38,6 +41,7 @@ namespace __iter_swap {
concept __unqualified_iter_swap =
(__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) &&
requires (_T1&& __x, _T2&& __y) {
+ // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
};
@@ -46,7 +50,9 @@ namespace __iter_swap {
indirectly_readable<_T1> && indirectly_readable<_T2> &&
swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>;
+
struct __fn {
+ // NOLINTBEGIN(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
template <class _T1, class _T2>
requires __unqualified_iter_swap<_T1, _T2>
_LIBCPP_HIDE_FROM_ABI
@@ -55,6 +61,7 @@ namespace __iter_swap {
{
(void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
}
+ // NOLINTEND(libcpp-robust-against-adl)
template <class _T1, class _T2>
requires (!__unqualified_iter_swap<_T1, _T2>) &&
@@ -75,7 +82,7 @@ namespace __iter_swap {
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>>()))
+ noexcept(*_VSTD::forward<_T1>(__x) = std::declval<iter_value_t<_T2>>()))
{
iter_value_t<_T2> __old(ranges::iter_move(__y));
*__y = ranges::iter_move(__x);
diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h
index 254f8c2339e4..c9d8944bfee3 100644
--- a/libcxx/include/__iterator/iterator_traits.h
+++ b/libcxx/include/__iterator/iterator_traits.h
@@ -10,11 +10,32 @@
#ifndef _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_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/same_as.h>
+#include <__concepts/totally_ordered.h>
#include <__config>
+#include <__fwd/pair.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/readable_traits.h>
-#include <concepts>
-#include <type_traits>
+#include <__type_traits/add_const.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_primary_template.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_valid_expansion.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -39,7 +60,7 @@ concept __dereferenceable = requires(_Tp& __t) {
// [iterator.traits]
template<__dereferenceable _Tp>
-using iter_reference_t = decltype(*declval<_Tp&>());
+using iter_reference_t = decltype(*std::declval<_Tp&>());
#endif // _LIBCPP_STD_VER > 17
@@ -106,11 +127,11 @@ struct __has_iterator_typedefs
{
private:
template <class _Up> static false_type __test(...);
- template <class _Up> static true_type __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);
+ template <class _Up> static true_type __test(__void_t<typename _Up::iterator_category>* = nullptr,
+ __void_t<typename _Up::difference_type>* = nullptr,
+ __void_t<typename _Up::value_type>* = nullptr,
+ __void_t<typename _Up::reference>* = nullptr,
+ __void_t<typename _Up::pointer>* = nullptr);
public:
static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;
};
@@ -252,7 +273,7 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typ
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->());
+ using type = decltype(std::declval<_Ip&>().operator->());
};
// Otherwise, `reference` names `iter-reference-t<I>`.
@@ -406,7 +427,7 @@ requires is_object_v<_Tp>
struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
{
typedef ptrdiff_t difference_type;
- typedef typename remove_cv<_Tp>::type value_type;
+ typedef __remove_cv_t<_Tp> value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
typedef random_access_iterator_tag iterator_category;
@@ -491,7 +512,7 @@ template<class _InputIterator>
using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
template<class _InputIterator>
-using __iter_key_type = typename remove_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type;
+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;
@@ -507,6 +528,12 @@ using __iterator_category_type = typename iterator_traits<_Iter>::iterator_categ
template <class _Iter>
using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer;
+template <class _Iter>
+using __iter_diff_t = typename iterator_traits<_Iter>::difference_type;
+
+template<class _InputIterator>
+using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
diff --git a/libcxx/include/__iterator/iterator_with_data.h b/libcxx/include/__iterator/iterator_with_data.h
new file mode 100644
index 000000000000..06c2fa699c30
--- /dev/null
+++ b/libcxx/include/__iterator/iterator_with_data.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___ITERATOR_ITERATOR_WITH_DATA_H
+#define _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
+
+#include <__compare/compare_three_way_result.h>
+#include <__compare/three_way_comparable.h>
+#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 <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <forward_iterator _Iterator, class _Data>
+class __iterator_with_data {
+ _Iterator __iter_{};
+ _Data __data_{};
+
+public:
+ using value_type = iter_value_t<_Iterator>;
+ using difference_type = iter_difference_t<_Iterator>;
+
+ _LIBCPP_HIDE_FROM_ABI __iterator_with_data() = default;
+
+ constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data(_Iterator __iter, _Data __data)
+ : __iter_(std::move(__iter)), __data_(std::move(__data)) {}
+
+ constexpr _LIBCPP_HIDE_FROM_ABI _Iterator __get_iter() const { return __iter_; }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI _Data __get_data() && { return std::move(__data_); }
+
+ friend constexpr _LIBCPP_HIDE_FROM_ABI bool
+ operator==(const __iterator_with_data& __lhs, const __iterator_with_data& __rhs) {
+ return __lhs.__iter_ == __rhs.__iter_;
+ }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator++() {
+ ++__iter_;
+ return *this;
+ }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator++(int) {
+ auto __tmp = *this;
+ __iter_++;
+ return __tmp;
+ }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator--()
+ requires bidirectional_iterator<_Iterator>
+ {
+ --__iter_;
+ return *this;
+ }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator--(int)
+ requires bidirectional_iterator<_Iterator>
+ {
+ auto __tmp = *this;
+ --__iter_;
+ return __tmp;
+ }
+
+ constexpr _LIBCPP_HIDE_FROM_ABI iter_reference_t<_Iterator> operator*() const { return *__iter_; }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iterator>
+ iter_move(const __iterator_with_data& __iter) noexcept(noexcept(ranges::iter_move(__iter.__iter_))) {
+ return ranges::iter_move(__iter.__iter_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr void
+ iter_swap(const __iterator_with_data& __lhs,
+ const __iterator_with_data& __rhs) noexcept(noexcept(ranges::iter_swap(__lhs.__iter_, __rhs.__iter_)))
+ requires indirectly_swappable<_Iterator>
+ {
+ return ranges::iter_swap(__lhs.__data_, __rhs.__iter_);
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
diff --git a/libcxx/include/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h
index 6be9f216dbb4..fa806dbaf70e 100644
--- a/libcxx/include/__iterator/move_iterator.h
+++ b/libcxx/include/__iterator/move_iterator.h
@@ -24,8 +24,16 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/move_sentinel.h>
#include <__iterator/readable_traits.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -49,7 +57,7 @@ struct __move_iter_category_base<_Iter> {
template<class _Iter, class _Sent>
concept __move_iter_comparable = requires {
- { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;
+ { std::declval<const _Iter&>() == std::declval<_Sent>() } -> convertible_to<bool>;
};
#endif // _LIBCPP_STD_VER > 17
@@ -82,18 +90,18 @@ public:
typedef typename iterator_traits<iterator_type>::reference __reference;
typedef typename conditional<
is_reference<__reference>::value,
- typename remove_reference<__reference>::type&&,
+ __libcpp_remove_reference_t<__reference>&&,
__reference
>::type reference;
#endif // _LIBCPP_STD_VER > 17
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator& operator++() { ++__current_; return *this; }
- _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
pointer operator->() const { return __current_; }
#if _LIBCPP_STD_VER > 17
@@ -133,13 +141,13 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr
void operator++(int) { ++__current_; }
#else
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator() : __current_() {}
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
template <class _Up, class = __enable_if_t<
@@ -147,35 +155,35 @@ public:
is_convertible<const _Up&, _Iter>::value &&
is_assignable<_Iter&, const _Up&>::value
> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator& operator=(const move_iterator<_Up>& __u) {
__current_ = __u.base();
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
_Iter base() const { return __current_; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
reference operator*() const { return static_cast<reference>(*__current_); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
#endif // _LIBCPP_STD_VER > 17
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator& operator--() { --__current_; return *this; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
#if _LIBCPP_STD_VER > 17
@@ -222,9 +230,10 @@ private:
_Iter __current_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_iterator);
template <class _Iter1, class _Iter2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() == __y.base();
@@ -232,7 +241,7 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
#if _LIBCPP_STD_VER <= 17
template <class _Iter1, class _Iter2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() != __y.base();
@@ -240,28 +249,28 @@ bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
#endif // _LIBCPP_STD_VER <= 17
template <class _Iter1, class _Iter2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() >= __y.base();
@@ -279,7 +288,7 @@ auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>&
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-> decltype(__x.base() - __y.base())
{
@@ -305,7 +314,7 @@ move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator
}
#else
template <class _Iter>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator<_Iter>
operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
{
@@ -314,7 +323,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
#endif // _LIBCPP_STD_VER > 17
template <class _Iter>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
move_iterator<_Iter>
make_move_iterator(_Iter __i)
{
diff --git a/libcxx/include/__iterator/move_sentinel.h b/libcxx/include/__iterator/move_sentinel.h
index 5adf877b3490..0d7336a1dc2a 100644
--- a/libcxx/include/__iterator/move_sentinel.h
+++ b/libcxx/include/__iterator/move_sentinel.h
@@ -50,6 +50,8 @@ private:
_Sent __last_ = _Sent();
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_sentinel);
+
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/next.h b/libcxx/include/__iterator/next.h
index 5363d6d58ecf..49970ae24808 100644
--- a/libcxx/include/__iterator/next.h
+++ b/libcxx/include/__iterator/next.h
@@ -16,7 +16,7 @@
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits>
+#include <__type_traits/enable_if.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,7 +25,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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,
@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
return __x;
}
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.iter.op.next]
@@ -77,7 +77,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/ostreambuf_iterator.h b/libcxx/include/__iterator/ostreambuf_iterator.h
index 6da7598ed272..b75f7b6e8466 100644
--- a/libcxx/include/__iterator/ostreambuf_iterator.h
+++ b/libcxx/include/__iterator/ostreambuf_iterator.h
@@ -65,7 +65,7 @@ public:
template <class _Ch, class _Tr>
friend
- _LIBCPP_HIDDEN
+ _LIBCPP_HIDE_FROM_ABI
ostreambuf_iterator<_Ch, _Tr>
__pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
diff --git a/libcxx/include/__iterator/prev.h b/libcxx/include/__iterator/prev.h
index eb997b91ba20..af1e1bab115b 100644
--- a/libcxx/include/__iterator/prev.h
+++ b/libcxx/include/__iterator/prev.h
@@ -16,7 +16,7 @@
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits>
+#include <__type_traits/enable_if.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,7 +25,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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,
@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
return __x;
}
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.iter.op.prev]
@@ -70,7 +70,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/projected.h b/libcxx/include/__iterator/projected.h
index 53526bd8e712..19c076b2e560 100644
--- a/libcxx/include/__iterator/projected.h
+++ b/libcxx/include/__iterator/projected.h
@@ -6,13 +6,14 @@
// 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>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/readable_traits.h b/libcxx/include/__iterator/readable_traits.h
index 500b46ac145f..8f17757c5a3d 100644
--- a/libcxx/include/__iterator/readable_traits.h
+++ b/libcxx/include/__iterator/readable_traits.h
@@ -10,9 +10,15 @@
#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
#define _LIBCPP___ITERATOR_READABLE_TRAITS_H
+#include <__concepts/same_as.h>
#include <__config>
-#include <concepts>
-#include <type_traits>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_primary_template.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_extent.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/reverse_access.h b/libcxx/include/__iterator/reverse_access.h
index 40c266378d36..79b599c47c12 100644
--- a/libcxx/include/__iterator/reverse_access.h
+++ b/libcxx/include/__iterator/reverse_access.h
@@ -24,70 +24,70 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 11
template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array);
}
template <class _Ep>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto rend(_Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto rend(const _Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
{
return _VSTD::rbegin(__c);
}
template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
{
return _VSTD::rend(__c);
diff --git a/libcxx/include/__iterator/reverse_iterator.h b/libcxx/include/__iterator/reverse_iterator.h
index 5c344c2ee310..f272e03c17a6 100644
--- a/libcxx/include/__iterator/reverse_iterator.h
+++ b/libcxx/include/__iterator/reverse_iterator.h
@@ -25,12 +25,20 @@
#include <__iterator/next.h>
#include <__iterator/prev.h>
#include <__iterator/readable_traits.h>
+#include <__iterator/segmented_iterator.h>
#include <__memory/addressof.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/subrange.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -52,7 +60,7 @@ class _LIBCPP_TEMPLATE_VIS reverse_iterator
_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
+ _Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break
#endif
#if _LIBCPP_STD_VER > 17
@@ -70,9 +78,7 @@ public:
typename iterator_traits<_Iter>::iterator_category>;
using pointer = typename iterator_traits<_Iter>::pointer;
#if _LIBCPP_STD_VER > 17
- using iterator_concept = _If<__is_cpp17_random_access_iterator<_Iter>::value,
- random_access_iterator_tag,
- bidirectional_iterator_tag>;
+ using iterator_concept = _If<random_access_iterator<_Iter>, random_access_iterator_tag, bidirectional_iterator_tag>;
using value_type = iter_value_t<_Iter>;
using difference_type = iter_difference_t<_Iter>;
using reference = iter_reference_t<_Iter>;
@@ -83,18 +89,18 @@ public:
#endif
#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator() : __t(), current() {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
+ reverse_iterator() : __t_(), current() {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
+ 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator(const reverse_iterator<_Up>& __u)
- : __t(__u.base()), current(__u.base())
+ : __t_(__u.base()), current(__u.base())
{ }
template <class _Up, class = __enable_if_t<
@@ -102,22 +108,22 @@ public:
is_convertible<_Up const&, _Iter>::value &&
is_assignable<_Iter&, _Up const&>::value
> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
- __t = current = __u.base();
+ __t_ = current = __u.base();
return *this;
}
#else
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator() : current() {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator(const reverse_iterator<_Up>& __u)
: current(__u.base())
{ }
@@ -127,15 +133,15 @@ public:
is_convertible<_Up const&, _Iter>::value &&
is_assignable<_Iter&, _Up const&>::value
> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
current = __u.base();
return *this;
}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
_Iter base() const {return current;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reference operator*() const {_Iter __tmp = current; return *--__tmp;}
#if _LIBCPP_STD_VER > 17
@@ -150,36 +156,36 @@ public:
}
}
#else
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
pointer operator->() const {
return std::addressof(operator*());
}
#endif // _LIBCPP_STD_VER > 17
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator++() {--current; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator--() {++current; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reference operator[](difference_type __n) const {return *(*this + __n);}
#if _LIBCPP_STD_VER > 17
_LIBCPP_HIDE_FROM_ABI friend constexpr
iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
noexcept(is_nothrow_copy_constructible_v<_Iter> &&
- noexcept(ranges::iter_move(--declval<_Iter&>()))) {
+ noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
auto __tmp = __i.base();
return ranges::iter_move(--__tmp);
}
@@ -189,7 +195,7 @@ public:
void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
noexcept(is_nothrow_copy_constructible_v<_Iter> &&
is_nothrow_copy_constructible_v<_Iter2> &&
- noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) {
+ noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
auto __xtmp = __x.base();
auto __ytmp = __y.base();
ranges::iter_swap(--__xtmp, --__ytmp);
@@ -197,14 +203,8 @@ public:
#endif // _LIBCPP_STD_VER > 17
};
-template <class _Iter>
-struct __is_reverse_iterator : false_type {};
-
-template <class _Iter>
-struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {};
-
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -217,7 +217,7 @@ operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
}
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -230,7 +230,7 @@ operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
}
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -243,7 +243,7 @@ operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
}
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -256,7 +256,7 @@ operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
}
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -269,7 +269,7 @@ operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
}
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
bool
operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
#if _LIBCPP_STD_VER > 17
@@ -293,7 +293,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
auto
operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-> decltype(__y.base() - __x.base())
@@ -311,7 +311,7 @@ operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
#endif
template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator<_Iter>
operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
{
@@ -326,7 +326,7 @@ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, rever
#if _LIBCPP_STD_VER > 11
template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
{
return reverse_iterator<_Iter>(__i);
@@ -365,7 +365,7 @@ class __unconstrained_reverse_iterator {
_Iter __iter_;
public:
- static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value);
+ static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>);
using iterator_type = _Iter;
using iterator_category =
@@ -393,6 +393,14 @@ public:
}
}
+ _LIBCPP_HIDE_FROM_ABI friend constexpr
+ iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)
+ noexcept(is_nothrow_copy_constructible_v<_Iter> &&
+ noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
+ auto __tmp = __i.base();
+ return ranges::iter_move(--__tmp);
+ }
+
_LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() {
--__iter_;
return *this;
@@ -472,9 +480,6 @@ public:
}
};
-template <class _Iter>
-struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {};
-
#endif // _LIBCPP_STD_VER <= 17
template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
@@ -493,7 +498,7 @@ struct __unwrap_reverse_iter_impl {
}
};
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
template <ranges::bidirectional_range _Range>
_LIBCPP_HIDE_FROM_ABI constexpr ranges::
subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>>
diff --git a/libcxx/include/__iterator/segmented_iterator.h b/libcxx/include/__iterator/segmented_iterator.h
new file mode 100644
index 000000000000..f3cd1e5fa1f5
--- /dev/null
+++ b/libcxx/include/__iterator/segmented_iterator.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___SEGMENTED_ITERATOR_H
+#define _LIBCPP___SEGMENTED_ITERATOR_H
+
+// Segmented iterators are iterators over (not necessarily contiguous) sub-ranges.
+//
+// For example, std::deque stores its data into multiple blocks of contiguous memory,
+// which are not stored contiguously themselves. The concept of segmented iterators
+// allows algorithms to operate over these multi-level iterators natively, opening the
+// door to various optimizations. See http://lafstern.org/matt/segmented.pdf for details.
+//
+// If __segmented_iterator_traits can be instantiated, the following functions and associated types must be provided:
+// - Traits::__local_iterator
+// The type of iterators used to iterate inside a segment.
+//
+// - Traits::__segment_iterator
+// The type of iterators used to iterate over segments.
+// Segment iterators can be forward iterators or bidirectional iterators, depending on the
+// underlying data structure.
+//
+// - static __segment_iterator Traits::__segment(It __it)
+// Returns an iterator to the segment that the provided iterator is in.
+//
+// - static __local_iterator Traits::__local(It __it)
+// Returns the local iterator pointing to the element that the provided iterator points to.
+//
+// - static __local_iterator Traits::__begin(__segment_iterator __it)
+// Returns the local iterator to the beginning of the segment that the provided iterator is pointing into.
+//
+// - static __local_iterator Traits::__end(__segment_iterator __it)
+// Returns the one-past-the-end local iterator to the segment that the provided iterator is pointing into.
+//
+// - static It Traits::__compose(__segment_iterator, __local_iterator)
+// Returns the iterator composed of the segment iterator and local iterator.
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Iterator>
+struct __segmented_iterator_traits;
+/* exposition-only:
+{
+ using __segment_iterator = ...;
+ using __local_iterator = ...;
+
+ static __segment_iterator __segment(_Iterator);
+ static __local_iterator __local(_Iterator);
+ static __local_iterator __begin(__segment_iterator);
+ static __local_iterator __end(__segment_iterator);
+ static _Iterator __compose(__segment_iterator, __local_iterator);
+};
+*/
+
+template <class _Tp, size_t = 0>
+struct __has_specialization : false_type {};
+
+template <class _Tp>
+struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};
+
+template <class _Iterator>
+using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___SEGMENTED_ITERATOR_H
diff --git a/libcxx/include/__iterator/size.h b/libcxx/include/__iterator/size.h
index e06013496668..1452bd1d55cd 100644
--- a/libcxx/include/__iterator/size.h
+++ b/libcxx/include/__iterator/size.h
@@ -11,8 +11,9 @@
#define _LIBCPP___ITERATOR_SIZE_H
#include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/make_signed.h>
#include <cstddef>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index f780048754c9..16defc1d8b02 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -15,7 +15,8 @@
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
#include <__memory/pointer_traits.h>
-#include <type_traits>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_convertible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -38,17 +39,17 @@ public:
#endif
private:
- iterator_type __i;
+ iterator_type __i_;
public:
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT
- : __i()
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT
+ : __i_()
{
_VSTD::__debug_db_insert_i(this);
}
- template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__wrap_iter(const __wrap_iter<_Up>& __u,
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
- : __i(__u.base())
+ : __i_(__u.base())
{
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
@@ -56,87 +57,87 @@ public:
#endif
}
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__wrap_iter(const __wrap_iter& __x)
- : __i(__x.base())
+ : __i_(__x.base())
{
if (!__libcpp_is_constant_evaluated())
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__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;
+ __i_ = __x.__i_;
}
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
~__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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable iterator");
- return *__i;
+ return *__i_;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable iterator");
- return _VSTD::__to_address(__i);
+ return _VSTD::__to_address(__i_);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator++() _NOEXCEPT
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to increment a non-incrementable iterator");
- ++__i;
+ ++__i_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator--() _NOEXCEPT
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
"Attempted to decrement a non-decrementable iterator");
- --__i;
+ --__i_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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;
+ __i_ += __n;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 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];
+ return __i_[__n];
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator_type base() const _NOEXCEPT {return __i_;}
private:
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+ explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i_(__x)
{
(void)__p;
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@@ -166,7 +167,7 @@ bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
}
template <class _Iter1>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
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)),
@@ -175,7 +176,7 @@ bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _
}
template <class _Iter1, class _Iter2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
@@ -240,7 +241,7 @@ bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
}
template <class _Iter1, class _Iter2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
#ifndef _LIBCPP_CXX03_LANG
auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-> decltype(__x.base() - __y.base())
@@ -255,7 +256,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
}
template <class _Iter1>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT
{
__x += __n;
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 40f9a3ff57c2..e0ffa0ca00ff 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -15,13 +15,15 @@
#include <cctype>
#include <cstdint>
#include <locale.h>
-#include <memory>
#include <mutex>
#include <string>
+// Some platforms require more includes than others. Keep the includes on all plaforms for now.
+#include <cstddef>
+#include <cstring>
+
#if defined(_LIBCPP_MSVCRT_LIKE)
# include <__support/win32/locale_win32.h>
-# include <cstring>
#elif defined(_AIX) || defined(__MVS__)
# include <__support/ibm/xlocale.h>
#elif defined(__ANDROID__)
@@ -191,12 +193,12 @@ protected:
explicit facet(size_t __refs = 0)
: __shared_count(static_cast<long>(__refs)-1) {}
- virtual ~facet();
+ ~facet() override;
// facet(const facet&) = delete; // effectively done in __shared_count
// void operator=(const facet&) = delete;
private:
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
};
class _LIBCPP_TYPE_VIS locale::id
@@ -291,7 +293,7 @@ public:
static locale::id id;
protected:
- ~collate();
+ ~collate() override;
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
@@ -350,7 +352,7 @@ template <>
class _LIBCPP_TYPE_VIS collate_byname<char>
: public collate<char>
{
- locale_t __l;
+ locale_t __l_;
public:
typedef char char_type;
typedef basic_string<char_type> string_type;
@@ -359,10 +361,10 @@ public:
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;
+ ~collate_byname() override;
+ int do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const override;
+ string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
};
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -370,7 +372,7 @@ template <>
class _LIBCPP_TYPE_VIS collate_byname<wchar_t>
: public collate<wchar_t>
{
- locale_t __l;
+ locale_t __l_;
public:
typedef wchar_t char_type;
typedef basic_string<char_type> string_type;
@@ -379,11 +381,11 @@ public:
explicit collate_byname(const string& __n, size_t __refs = 0);
protected:
- ~collate_byname();
+ ~collate_byname() override;
- 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;
+ int do_compare(const char_type* __lo1, const char_type* __hi1,
+ const char_type* __lo2, const char_type* __hi2) const override;
+ string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
};
#endif
@@ -510,7 +512,8 @@ public:
static const mask punct = _P;
static const mask xdigit = _X | _N;
static const mask blank = _B;
- static const mask __regex_word = 0x80;
+ // mask is already fully saturated, use a different type in regex_type_traits.
+ static const unsigned short __regex_word = 0x100;
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
@@ -549,7 +552,8 @@ public:
_LIBCPP_INLINE_VISIBILITY ctype_base() {}
- static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,
+ static_assert((__regex_word & ~(std::make_unsigned<mask>::type)(space | print | cntrl | upper | lower | alpha |
+ digit | punct | xdigit | blank)) == __regex_word,
"__regex_word can't overlap other bits");
};
@@ -643,7 +647,7 @@ public:
static locale::id id;
protected:
- ~ctype();
+ ~ctype() override;
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;
@@ -697,7 +701,7 @@ public:
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)))
+ if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
break;
return __low;
}
@@ -773,7 +777,7 @@ public:
#endif
protected:
- ~ctype();
+ ~ctype() override;
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;
@@ -792,18 +796,18 @@ template <>
class _LIBCPP_TYPE_VIS ctype_byname<char>
: public ctype<char>
{
- locale_t __l;
+ 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;
+ ~ctype_byname() override;
+ char_type do_toupper(char_type) const override;
+ const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
+ char_type do_tolower(char_type) const override;
+ const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
};
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -811,26 +815,26 @@ template <>
class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
: public ctype<wchar_t>
{
- locale_t __l;
+ 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;
+ ~ctype_byname() override;
+ bool do_is(mask __m, char_type __c) const override;
+ const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override;
+ const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override;
+ const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override;
+ char_type do_toupper(char_type) const override;
+ const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
+ char_type do_tolower(char_type) const override;
+ const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
+ char_type do_widen(char) const override;
+ const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override;
+ char do_narrow(char_type, char __dfault) const override;
+ const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -839,7 +843,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isspace(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
}
template <class _CharT>
@@ -847,7 +851,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isprint(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
}
template <class _CharT>
@@ -855,7 +859,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
iscntrl(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
}
template <class _CharT>
@@ -863,7 +867,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isupper(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
}
template <class _CharT>
@@ -871,7 +875,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
islower(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
}
template <class _CharT>
@@ -879,7 +883,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isalpha(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
}
template <class _CharT>
@@ -887,7 +891,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isdigit(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
}
template <class _CharT>
@@ -895,7 +899,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
ispunct(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
}
template <class _CharT>
@@ -903,7 +907,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isxdigit(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
}
template <class _CharT>
@@ -911,7 +915,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isalnum(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
}
template <class _CharT>
@@ -919,7 +923,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
isgraph(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
+ return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
}
template <class _CharT>
@@ -927,7 +931,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_CharT
toupper(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).toupper(__c);
+ return std::use_facet<ctype<_CharT> >(__loc).toupper(__c);
}
template <class _CharT>
@@ -935,7 +939,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_CharT
tolower(_CharT __c, const locale& __loc)
{
- return use_facet<ctype<_CharT> >(__loc).tolower(__c);
+ return std::use_facet<ctype<_CharT> >(__loc).tolower(__c);
}
// codecvt_base
@@ -1021,7 +1025,7 @@ protected:
explicit codecvt(const char*, size_t __refs = 0)
: locale::facet(__refs) {}
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1045,7 +1049,7 @@ class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
: public locale::facet,
public codecvt_base
{
- locale_t __l;
+ locale_t __l_;
public:
typedef wchar_t intern_type;
typedef char extern_type;
@@ -1105,7 +1109,7 @@ public:
protected:
explicit codecvt(const char*, size_t __refs = 0);
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1192,7 +1196,7 @@ protected:
explicit codecvt(const char*, size_t __refs = 0)
: locale::facet(__refs) {}
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1280,7 +1284,7 @@ protected:
explicit codecvt(const char*, size_t __refs = 0)
: locale::facet(__refs) {}
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1368,7 +1372,7 @@ protected:
explicit codecvt(const char*, size_t __refs = 0)
: locale::facet(__refs) {}
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1456,7 +1460,7 @@ protected:
explicit codecvt(const char*, size_t __refs = 0)
: locale::facet(__refs) {}
- ~codecvt();
+ ~codecvt() override;
virtual result do_out(state_type& __st,
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
@@ -1488,7 +1492,7 @@ public:
explicit codecvt_byname(const string& __nm, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
protected:
- ~codecvt_byname();
+ ~codecvt_byname() override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -1540,7 +1544,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<16>
__narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- ~__narrow_to_utf8();
+ ~__narrow_to_utf8() override;
template <class _OutputIterator, class _CharT>
_LIBCPP_INLINE_VISIBILITY
@@ -1576,7 +1580,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<32>
__narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- ~__narrow_to_utf8();
+ ~__narrow_to_utf8() override;
template <class _OutputIterator, class _CharT>
_LIBCPP_INLINE_VISIBILITY
@@ -1634,7 +1638,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<16>
__widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- ~__widen_from_utf8();
+ ~__widen_from_utf8() override;
template <class _OutputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -1670,7 +1674,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<32>
__widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- ~__widen_from_utf8();
+ ~__widen_from_utf8() override;
template <class _OutputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -1720,7 +1724,7 @@ public:
static locale::id id;
protected:
- ~numpunct();
+ ~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
@@ -1752,7 +1756,7 @@ public:
static locale::id id;
protected:
- ~numpunct();
+ ~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
@@ -1781,7 +1785,7 @@ public:
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
- ~numpunct_byname();
+ ~numpunct_byname() override;
private:
void __init(const char*);
@@ -1800,7 +1804,7 @@ public:
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
- ~numpunct_byname();
+ ~numpunct_byname() override;
private:
void __init(const char*);
diff --git a/libcxx/include/__memory/addressof.h b/libcxx/include/__memory/addressof.h
index 75e3dd0647b2..d4c69b83a8dc 100644
--- a/libcxx/include/__memory/addressof.h
+++ b/libcxx/include/__memory/addressof.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
_Tp*
addressof(_Tp& __x) _NOEXCEPT
diff --git a/libcxx/include/__memory/align.h b/libcxx/include/__memory/align.h
new file mode 100644
index 000000000000..c6792206b075
--- /dev/null
+++ b/libcxx/include/__memory/align.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___MEMORY_ALIGN_H
+#define _LIBCPP___MEMORY_ALIGN_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ALIGN_H
diff --git a/libcxx/include/__memory/allocate_at_least.h b/libcxx/include/__memory/allocate_at_least.h
index 7ce588a25d1b..ef205f855cb2 100644
--- a/libcxx/include/__memory/allocate_at_least.h
+++ b/libcxx/include/__memory/allocate_at_least.h
@@ -25,6 +25,7 @@ struct allocation_result {
_Pointer ptr;
size_t count;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
template <class _Alloc>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
diff --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index 57ce23483df3..54c9b78d524d 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -13,11 +13,14 @@
#include <__config>
#include <__memory/allocate_at_least.h>
#include <__memory/allocator_traits.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/is_volatile.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
@@ -95,14 +98,14 @@ public:
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
allocator() _NOEXCEPT = default;
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
allocator(const allocator<_Up>&) _NOEXCEPT { }
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp* allocate(size_t __n) {
if (__n > allocator_traits<allocator>::max_size(*this))
__throw_bad_array_new_length();
@@ -120,7 +123,7 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
if (__libcpp_is_constant_evaluated()) {
::operator delete(__p);
@@ -184,14 +187,14 @@ public:
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
allocator() _NOEXCEPT = default;
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
allocator(const allocator<_Up>&) _NOEXCEPT { }
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
const _Tp* allocate(size_t __n) {
if (__n > allocator_traits<allocator>::max_size(*this))
__throw_bad_array_new_length();
@@ -209,7 +212,7 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void deallocate(const _Tp* __p, size_t __n) {
if (__libcpp_is_constant_evaluated()) {
::operator delete(const_cast<_Tp*>(__p));
@@ -258,11 +261,11 @@ public:
};
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__memory/allocator_arg_t.h b/libcxx/include/__memory/allocator_arg_t.h
index 2d63b1f905e5..15f8c98c4c90 100644
--- a/libcxx/include/__memory/allocator_arg_t.h
+++ b/libcxx/include/__memory/allocator_arg_t.h
@@ -12,8 +12,10 @@
#include <__config>
#include <__memory/uses_allocator.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,7 +38,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
- typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;
+ typedef _LIBCPP_NODEBUG __remove_cvref_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;
diff --git a/libcxx/include/__memory/allocator_destructor.h b/libcxx/include/__memory/allocator_destructor.h
new file mode 100644
index 000000000000..623ad8ad800a
--- /dev/null
+++ b/libcxx/include/__memory/allocator_destructor.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___MEMORY_ALLOCATOR_DESTRUCTOR_H
+#define _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+
+#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_);}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H
diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
index 5215556cdf3c..3a23b47c74b3 100644
--- a/libcxx/include/__memory/allocator_traits.h
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -13,9 +13,16 @@
#include <__config>
#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_empty.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_reference.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#include <limits>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,12 +35,12 @@ _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 { }
+ template <class _Tp> struct NAME<_Tp, __void_t<typename _Tp:: PROPERTY > > : true_type { }
// __pointer
_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
template <class _Tp, class _Alloc,
- class _RawAlloc = typename remove_reference<_Alloc>::type,
+ class _RawAlloc = __libcpp_remove_reference_t<_Alloc>,
bool = __has_pointer<_RawAlloc>::value>
struct __pointer {
using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
@@ -152,13 +159,12 @@ _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 { };
+struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > : 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;
+ static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement 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> {
@@ -181,7 +187,7 @@ 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>())
+ (void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>())
)> : true_type { };
// __has_construct
@@ -190,7 +196,7 @@ struct __has_construct_impl : false_type { };
template <class _Alloc, class ..._Args>
struct __has_construct_impl<decltype(
- (void)declval<_Alloc>().construct(declval<_Args>()...)
+ (void)std::declval<_Alloc>().construct(std::declval<_Args>()...)
), _Alloc, _Args...> : true_type { };
template <class _Alloc, class ..._Args>
@@ -202,7 +208,7 @@ struct __has_destroy : false_type { };
template <class _Alloc, class _Pointer>
struct __has_destroy<_Alloc, _Pointer, decltype(
- (void)declval<_Alloc>().destroy(declval<_Pointer>())
+ (void)std::declval<_Alloc>().destroy(std::declval<_Pointer>())
)> : true_type { };
// __has_max_size
@@ -211,7 +217,7 @@ struct __has_max_size : false_type { };
template <class _Alloc>
struct __has_max_size<_Alloc, decltype(
- (void)declval<_Alloc&>().max_size()
+ (void)std::declval<_Alloc&>().max_size()
)> : true_type { };
// __has_select_on_container_copy_construction
@@ -220,7 +226,7 @@ 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()
+ (void)std::declval<_Alloc>().select_on_container_copy_construction()
)> : true_type { };
_LIBCPP_SUPPRESS_DEPRECATED_POP
@@ -257,14 +263,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
};
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
return __a.allocate(__n, __hint);
@@ -272,19 +278,19 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
}
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
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {
return __a.allocate(__n);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
__a.construct(__p, _VSTD::forward<_Args>(__args)...);
@@ -292,7 +298,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
}
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
#if _LIBCPP_STD_VER > 17
_VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
@@ -303,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
template <class _Tp, class =
__enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void destroy(allocator_type& __a, _Tp* __p) {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
__a.destroy(__p);
@@ -311,7 +317,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
}
template <class _Tp, class = void, class =
__enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void destroy(allocator_type&, _Tp* __p) {
#if _LIBCPP_STD_VER > 17
_VSTD::destroy_at(__p);
@@ -322,7 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
template <class _Ap = _Alloc, class =
__enable_if_t<__has_max_size<const _Ap>::value> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static size_type max_size(const allocator_type& __a) _NOEXCEPT {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
return __a.max_size();
@@ -330,33 +336,32 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
}
template <class _Ap = _Alloc, class = void, class =
__enable_if_t<!__has_max_size<const _Ap>::value> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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>;
+template <class _Traits, class _Tp>
+using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
#else
- using type = typename _Traits::template rebind_alloc<_Tp>::other;
+template <class _Traits, class _Tp>
+using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
#endif
-};
// __is_default_allocator
template <class _Tp>
diff --git a/libcxx/include/__memory/assume_aligned.h b/libcxx/include/__memory/assume_aligned.h
index 0f12fb11fd86..a1fd2441f9a9 100644
--- a/libcxx/include/__memory/assume_aligned.h
+++ b/libcxx/include/__memory/assume_aligned.h
@@ -12,9 +12,9 @@
#include <__assert>
#include <__config>
+#include <__type_traits/is_constant_evaluated.h>
#include <cstddef>
#include <cstdint>
-#include <type_traits> // for is_constant_evaluated()
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__memory/builtin_new_allocator.h b/libcxx/include/__memory/builtin_new_allocator.h
new file mode 100644
index 000000000000..cd1a866ca615
--- /dev/null
+++ b/libcxx/include/__memory/builtin_new_allocator.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___MEMORY_BUILTIN_NEW_ALLOCATOR_H
+#define _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
+
+#include <__config>
+#include <__memory/unique_ptr.h>
+#include <cstddef>
+#include <new>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __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
+
+#endif // _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
diff --git a/libcxx/include/__memory/compressed_pair.h b/libcxx/include/__memory/compressed_pair.h
index 89e5820e992a..8093d7c93156 100644
--- a/libcxx/include/__memory/compressed_pair.h
+++ b/libcxx/include/__memory/compressed_pair.h
@@ -11,10 +11,21 @@
#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
#include <__config>
+#include <__fwd/get.h>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/dependent_type.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_empty.h>
+#include <__type_traits/is_final.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <tuple> // needed in c++03 for some constructors
-#include <type_traits>
+#include <__utility/piecewise_construct.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -41,12 +52,12 @@ struct __compressed_pair_elem {
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args, size_t... _Indices>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
explicit __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_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
private:
@@ -70,12 +81,12 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args, size_t... _Indices>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
__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_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
};
@@ -109,14 +120,14 @@ public:
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
explicit __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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
typename _Base1::reference first() _NOEXCEPT {
return static_cast<_Base1&>(*this).__get();
}
@@ -126,7 +137,7 @@ public:
return static_cast<_Base1 const&>(*this).__get();
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
typename _Base2::reference second() _NOEXCEPT {
return static_cast<_Base2&>(*this).__get();
}
@@ -145,7 +156,7 @@ public:
return static_cast<_Base2*>(__pair);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
void swap(__compressed_pair& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
using std::swap;
@@ -155,7 +166,7 @@ public:
};
template <class _T1, class _T2>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
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);
diff --git a/libcxx/include/__memory/concepts.h b/libcxx/include/__memory/concepts.h
index 88372d277d7f..12d7bf85ed94 100644
--- a/libcxx/include/__memory/concepts.h
+++ b/libcxx/include/__memory/concepts.h
@@ -10,14 +10,15 @@
#ifndef _LIBCPP___MEMORY_CONCEPTS_H
#define _LIBCPP___MEMORY_CONCEPTS_H
+#include <__concepts/same_as.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>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cvref.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -61,7 +62,7 @@ concept __nothrow_forward_range =
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h
index bfa20a149d51..ffee0022c243 100644
--- a/libcxx/include/__memory/construct_at.h
+++ b/libcxx/include/__memory/construct_at.h
@@ -15,9 +15,12 @@
#include <__iterator/access.h>
#include <__memory/addressof.h>
#include <__memory/voidify.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_array.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
+template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
_LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
@@ -37,12 +40,13 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __
#endif
-template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
+template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
#if _LIBCPP_STD_VER > 17
return std::construct_at(__location, std::forward<_Args>(__args)...);
#else
- return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
+ return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
+ ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
#endif
}
@@ -52,11 +56,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
// taking an array).
template <class _ForwardIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __destroy_at(_Tp* __loc) {
_LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
__loc->~_Tp();
@@ -64,7 +68,7 @@ void __destroy_at(_Tp* __loc) {
#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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __destroy_at(_Tp* __loc) {
_LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
_VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
@@ -72,7 +76,7 @@ void __destroy_at(_Tp* __loc) {
#endif
template <class _ForwardIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
for (; __first != __last; ++__first)
_VSTD::__destroy_at(_VSTD::addressof(*__first));
@@ -82,27 +86,27 @@ _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
#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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void destroy_at(_Tp* __loc) {
_VSTD::__destroy_at(__loc);
}
#endif
template <class _ForwardIterator>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
for (; __n > 0; (void)++__first, --__n)
_VSTD::__destroy_at(_VSTD::addressof(*__first));
diff --git a/libcxx/include/__memory/destruct_n.h b/libcxx/include/__memory/destruct_n.h
new file mode 100644
index 000000000000..2cfb2e4c88ce
--- /dev/null
+++ b/libcxx/include/__memory/destruct_n.h
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_DESTRUCT_N_H
+#define _LIBCPP___MEMORY_DESTRUCT_N_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_DESTRUCT_N_H
diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 2549e4be7df1..c4f20def4540 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -12,7 +12,15 @@
#include <__config>
#include <__memory/addressof.h>
-#include <type_traits>
+#include <__type_traits/conditional.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,8 +32,7 @@ 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 {};
+struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {};
template <class _Ptr, bool = __has_element_type<_Ptr>::value>
struct __pointer_traits_element_type;
@@ -52,8 +59,7 @@ 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 {};
+struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : true_type {};
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
struct __pointer_traits_difference_type
@@ -122,9 +128,8 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
private:
struct __nat {};
public:
- _LIBCPP_INLINE_VISIBILITY
- static pointer pointer_to(typename conditional<is_void<element_type>::value,
- __nat, element_type>::type& __r)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+ static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r)
{return pointer::pointer_to(__r);}
};
@@ -144,20 +149,18 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+ static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_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;
+template <class _From, class _To>
+using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>;
#else
- typedef typename pointer_traits<_From>::template rebind<_To>::other type;
+template <class _From, class _To>
+using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>::other;
#endif
-};
// to_address
@@ -171,12 +174,33 @@ _Tp* __to_address(_Tp* __p) _NOEXCEPT {
return __p;
}
+template <class _Pointer, class = void>
+struct _HasToAddress : false_type {};
+
+template <class _Pointer>
+struct _HasToAddress<_Pointer,
+ decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
+> : true_type {};
+
+template <class _Pointer, class = void>
+struct _HasArrow : false_type {};
+
+template <class _Pointer>
+struct _HasArrow<_Pointer,
+ decltype((void)std::declval<const _Pointer&>().operator->())
+> : true_type {};
+
+template <class _Pointer>
+struct _IsFancyPointer {
+ static const bool value = _HasArrow<_Pointer>::value || _HasToAddress<_Pointer>::value;
+};
+
// 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
+ _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
> >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type
+typename decay<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>::type
__to_address(const _Pointer& __p) _NOEXCEPT {
return __to_address_helper<_Pointer>::__call(__p);
}
@@ -184,16 +208,16 @@ __to_address(const _Pointer& __p) _NOEXCEPT {
template <class _Pointer, class>
struct __to_address_helper {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static decltype(_VSTD::__to_address(declval<const _Pointer&>().operator->()))
+ static decltype(_VSTD::__to_address(std::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&>()))> {
+struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
+ static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
__call(const _Pointer& __p) _NOEXCEPT {
return pointer_traits<_Pointer>::to_address(__p);
}
@@ -208,7 +232,7 @@ auto to_address(_Tp *__p) noexcept {
template <class _Pointer>
inline _LIBCPP_INLINE_VISIBILITY constexpr
-auto to_address(const _Pointer& __p) noexcept {
+auto to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {
return _VSTD::__to_address(__p);
}
#endif
diff --git a/libcxx/include/__memory/ranges_construct_at.h b/libcxx/include/__memory/ranges_construct_at.h
index 29258023e3f9..e63585d1ab63 100644
--- a/libcxx/include/__memory/ranges_construct_at.h
+++ b/libcxx/include/__memory/ranges_construct_at.h
@@ -22,6 +22,7 @@
#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,7 +30,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
// construct_at
@@ -38,7 +39,7 @@ namespace __construct_at {
struct __fn {
template<class _Tp, class... _Args, class = decltype(
- ::new (declval<void*>()) _Tp(declval<_Args>()...)
+ ::new (std::declval<void*>()) _Tp(std::declval<_Args>()...)
)>
_LIBCPP_HIDE_FROM_ABI
constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {
@@ -117,7 +118,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/libcxx/include/__memory/ranges_uninitialized_algorithms.h
index 8072496c24d6..15c78e20bafb 100644
--- a/libcxx/include/__memory/ranges_uninitialized_algorithms.h
+++ b/libcxx/include/__memory/ranges_uninitialized_algorithms.h
@@ -23,8 +23,9 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
+#include <__type_traits/remove_reference.h>
#include <__utility/move.h>
-#include <type_traits>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -32,7 +33,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -255,7 +256,7 @@ struct __fn {
sentinel_for<_InputIterator> _Sentinel1,
__nothrow_forward_iterator _OutputIterator,
__nothrow_sentinel_for<_OutputIterator> _Sentinel2>
- requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_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>>;
@@ -266,7 +267,7 @@ struct __fn {
}
template <input_range _InputRange, __nothrow_forward_range _OutputRange>
- requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>>
+ requires constructible_from<range_value_t<_OutputRange>, range_rvalue_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),
@@ -291,7 +292,7 @@ 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>>
+ requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>>
uninitialized_move_n_result<_InputIterator, _OutputIterator>
operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,
_OutputIterator __ofirst, _Sentinel __olast) const {
@@ -311,7 +312,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__memory/raw_storage_iterator.h b/libcxx/include/__memory/raw_storage_iterator.h
index 9b6594b8883e..11971de0fa47 100644
--- a/libcxx/include/__memory/raw_storage_iterator.h
+++ b/libcxx/include/__memory/raw_storage_iterator.h
@@ -16,6 +16,7 @@
#include <__memory/addressof.h>
#include <__utility/move.h>
#include <cstddef>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 41a7c7fa7575..b77ce9230bff 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -11,6 +11,8 @@
#define _LIBCPP___MEMORY_SHARED_PTR_H
#include <__availability>
+#include <__compare/compare_three_way.h>
+#include <__compare/ordering.h>
#include <__config>
#include <__functional/binary_function.h>
#include <__functional/operations.h>
@@ -19,6 +21,7 @@
#include <__memory/addressof.h>
#include <__memory/allocation_guard.h>
#include <__memory/allocator.h>
+#include <__memory/allocator_destructor.h>
#include <__memory/allocator_traits.h>
#include <__memory/auto_ptr.h>
#include <__memory/compressed_pair.h>
@@ -32,39 +35,19 @@
#include <cstddef>
#include <cstdlib> // abort
#include <iosfwd>
+#include <new>
#include <stdexcept>
-#include <type_traits>
#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
#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
@@ -128,8 +111,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
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;
+ ~bad_weak_ptr() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
@@ -194,7 +177,7 @@ public:
: __shared_count(__refs),
__shared_weak_owners_(__refs) {}
protected:
- virtual ~__shared_weak_count();
+ ~__shared_weak_count() override;
public:
#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
@@ -237,12 +220,12 @@ public:
: __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;
+ const void* __get_deleter(const type_info&) const _NOEXCEPT override;
#endif
private:
- virtual void __on_zero_shared() _NOEXCEPT;
- virtual void __on_zero_shared_weak() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
+ void __on_zero_shared_weak() _NOEXCEPT override;
};
#ifndef _LIBCPP_NO_RTTI
@@ -277,6 +260,8 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
__a.deallocate(_PTraits::pointer_to(*this), 1);
}
+struct __default_initialize_tag {};
+
template <class _Tp, class _Alloc>
struct __shared_ptr_emplace
: __shared_weak_count
@@ -295,6 +280,16 @@ struct __shared_ptr_emplace
#endif
}
+
+#if _LIBCPP_STD_VER >= 20
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __shared_ptr_emplace(__default_initialize_tag, _Alloc __a)
+ : __storage_(std::move(__a))
+ {
+ ::new ((void*)__get_elem()) _Tp;
+ }
+#endif
+
_LIBCPP_HIDE_FROM_ABI
_Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
@@ -302,7 +297,7 @@ struct __shared_ptr_emplace
_Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
private:
- virtual void __on_zero_shared() _NOEXCEPT {
+ void __on_zero_shared() _NOEXCEPT override {
#if _LIBCPP_STD_VER > 17
using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
_TpAlloc __tmp(*__get_alloc());
@@ -312,7 +307,7 @@ private:
#endif
}
- virtual void __on_zero_shared_weak() _NOEXCEPT {
+ void __on_zero_shared_weak() _NOEXCEPT override {
using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
_ControlBlockAlloc __tmp(*__get_alloc());
@@ -383,22 +378,22 @@ struct __compatible_with
template <class _Ptr, class = void>
struct __is_deletable : false_type { };
template <class _Ptr>
-struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { };
+struct __is_deletable<_Ptr, decltype(delete std::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 { };
+struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : true_type { };
template <class _Dp, class _Pt,
- class = decltype(declval<_Dp>()(declval<_Pt>()))>
+ class = decltype(std::declval<_Dp>()(std::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)) {};
+struct __well_formed_deleter : decltype(std::__well_formed_deleter_test<_Dp, _Pt>(0)) {};
template<class _Dp, class _Tp, class _Yp>
struct __shared_ptr_deleter_ctor_reqs
@@ -687,7 +682,7 @@ public:
{
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>,
+ reference_wrapper<__libcpp_remove_reference_t<_Dp> >,
_AllocT> _CntrlBlk;
__cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
__enable_weak_this(__r.get(), __r.get());
@@ -802,7 +797,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
+ __add_lvalue_reference_t<element_type> operator*() const _NOEXCEPT
{
return *__ptr_;
}
@@ -855,7 +850,7 @@ public:
#if _LIBCPP_STD_VER > 14
_LIBCPP_HIDE_FROM_ABI
- typename add_lvalue_reference<element_type>::type operator[](ptrdiff_t __i) const
+ __add_lvalue_reference_t<element_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.");
@@ -904,7 +899,7 @@ private:
_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;
+ typedef __remove_cv_t<_Yp> _RawYp;
if (__e && __e->__weak_this_.expired())
{
__e->__weak_this_ = shared_ptr<_RawYp>(*this,
@@ -962,6 +957,29 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)
return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
}
+#if _LIBCPP_STD_VER >= 20
+
+template<class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a)
+{
+ 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(__default_initialize_tag{}, __a);
+ 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, __enable_if_t<!is_array<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> make_shared_for_overwrite()
+{
+ return std::allocate_shared_for_overwrite<_Tp>(allocator<_Tp>());
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
#if _LIBCPP_STD_VER > 14
template <size_t _Alignment>
@@ -992,6 +1010,17 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_);
}
+#if _LIBCPP_STD_VER >= 20
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count, __default_initialize_tag)
+ : __alloc_(__alloc), __count_(__count)
+ {
+ // We are purposefully not using an allocator-aware default construction because the spec says so.
+ // There's currently no way of expressing default initialization in an allocator-aware manner anyway.
+ std::uninitialized_default_construct_n(std::begin(__data_), __count_);
+ }
+#endif
+
// Returns the number of bytes required to store a control block followed by the given number
// of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.
_LIBCPP_HIDE_FROM_ABI
@@ -1008,7 +1037,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
return (__bytes + __align - 1) & ~(__align - 1);
}
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
private:
@@ -1075,7 +1104,16 @@ struct __bounded_array_control_block<_Tp[_Count], _Alloc>
std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count);
}
+#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI
+ explicit __bounded_array_control_block(_Alloc const& __alloc, __default_initialize_tag) : __alloc_(__alloc) {
+ // We are purposefully not using an allocator-aware default construction because the spec says so.
+ // There's currently no way of expressing default initialization in an allocator-aware manner anyway.
+ std::uninitialized_default_construct_n(std::addressof(__data_[0]), _Count);
+ }
+#endif
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
private:
@@ -1118,6 +1156,7 @@ shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ...
#if _LIBCPP_STD_VER > 17
+// bounded array variants
template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
_LIBCPP_HIDE_FROM_ABI
shared_ptr<_Tp> allocate_shared(const _Alloc& __a)
@@ -1132,18 +1171,11 @@ shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& _
return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
}
-template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
+template<class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI
-shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n)
+shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a)
{
- return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
-}
-
-template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
-_LIBCPP_HIDE_FROM_ABI
-shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u)
-{
- return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
+ return std::__allocate_shared_bounded_array<_Tp>(__a, __default_initialize_tag{});
}
template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
@@ -1160,6 +1192,35 @@ shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u)
return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
}
+template<class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> make_shared_for_overwrite()
+{
+ return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __default_initialize_tag{});
+}
+
+// unbounded array variants
+template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n)
+{
+ return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
+}
+
+template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u)
+{
+ return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
+}
+
+template<class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a, size_t __n)
+{
+ return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __default_initialize_tag{});
+}
+
template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
_LIBCPP_HIDE_FROM_ABI
shared_ptr<_Tp> make_shared(size_t __n)
@@ -1174,6 +1235,13 @@ shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u)
return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
}
+template<class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> make_shared_for_overwrite(size_t __n)
+{
+ return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __default_initialize_tag{});
+}
+
#endif // _LIBCPP_STD_VER > 17
template<class _Tp, class _Up>
@@ -1184,6 +1252,8 @@ operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
return __x.get() == __y.get();
}
+#if _LIBCPP_STD_VER <= 17
+
template<class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -1230,6 +1300,17 @@ operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
return !(__x < __y);
}
+#endif // _LIBCPP_STD_VER <= 17
+
+#if _LIBCPP_STD_VER > 17
+template<class _Tp, class _Up>
+_LIBCPP_HIDE_FROM_ABI strong_ordering
+operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept
+{
+ return compare_three_way()(__x.get(), __y.get());
+}
+#endif
+
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -1238,6 +1319,8 @@ operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
return !__x;
}
+#if _LIBCPP_STD_VER <= 17
+
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -1326,6 +1409,17 @@ operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
return !(nullptr < __x);
}
+#endif // _LIBCPP_STD_VER <= 17
+
+#if _LIBCPP_STD_VER > 17
+template<class _Tp>
+_LIBCPP_HIDE_FROM_ABI strong_ordering
+operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept
+{
+ return compare_three_way()(__x.get(), static_cast<typename shared_ptr<_Tp>::element_type*>(nullptr));
+}
+#endif
+
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
@@ -1355,7 +1449,7 @@ dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
}
template<class _Tp, class _Up>
-shared_ptr<_Tp>
+_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
{
typedef typename shared_ptr<_Tp>::element_type _RTp;
@@ -1363,7 +1457,7 @@ const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
}
template<class _Tp, class _Up>
-shared_ptr<_Tp>
+_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
{
return shared_ptr<_Tp>(__r,
@@ -1771,7 +1865,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
class _LIBCPP_TYPE_VIS __sp_mut
{
- void* __lx;
+ void* __lx_;
public:
void lock() _NOEXCEPT;
void unlock() _NOEXCEPT;
@@ -1797,10 +1891,10 @@ atomic_is_lock_free(const shared_ptr<_Tp>*)
template <class _Tp>
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
+_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
atomic_load(const shared_ptr<_Tp>* __p)
{
- __sp_mut& __m = __get_sp_mut(__p);
+ __sp_mut& __m = std::__get_sp_mut(__p);
__m.lock();
shared_ptr<_Tp> __q = *__p;
__m.unlock();
@@ -1813,15 +1907,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
shared_ptr<_Tp>
atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
{
- return atomic_load(__p);
+ return std::atomic_load(__p);
}
template <class _Tp>
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-void
+_LIBCPP_HIDE_FROM_ABI void
atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
{
- __sp_mut& __m = __get_sp_mut(__p);
+ __sp_mut& __m = std::__get_sp_mut(__p);
__m.lock();
__p->swap(__r);
__m.unlock();
@@ -1833,15 +1927,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
void
atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
{
- atomic_store(__p, __r);
+ std::atomic_store(__p, __r);
}
template <class _Tp>
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
+_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
{
- __sp_mut& __m = __get_sp_mut(__p);
+ __sp_mut& __m = std::__get_sp_mut(__p);
__m.lock();
__p->swap(__r);
__m.unlock();
@@ -1854,16 +1948,16 @@ _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);
+ return std::atomic_exchange(__p, __r);
}
template <class _Tp>
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-bool
+_LIBCPP_HIDE_FROM_ABI 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);
+ __sp_mut& __m = std::__get_sp_mut(__p);
__m.lock();
if (__p->__owner_equivalent(*__v))
{
@@ -1884,7 +1978,7 @@ _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);
+ return std::atomic_compare_exchange_strong(__p, __v, __w);
}
template <class _Tp>
@@ -1894,7 +1988,7 @@ 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);
+ return std::atomic_compare_exchange_strong(__p, __v, __w);
}
template <class _Tp>
@@ -1904,7 +1998,7 @@ 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);
+ return std::atomic_compare_exchange_weak(__p, __v, __w);
}
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
diff --git a/libcxx/include/__memory/swap_allocator.h b/libcxx/include/__memory/swap_allocator.h
index 64970fa9e2f4..c6e1751f4ddc 100644
--- a/libcxx/include/__memory/swap_allocator.h
+++ b/libcxx/include/__memory/swap_allocator.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__memory/allocator_traits.h>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_swappable.h>
#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <typename _Alloc>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
#if _LIBCPP_STD_VER > 11
_NOEXCEPT
#else
@@ -33,11 +34,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc
}
template <typename _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 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)
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
#if _LIBCPP_STD_VER > 11
_NOEXCEPT
#else
diff --git a/libcxx/include/__memory/temp_value.h b/libcxx/include/__memory/temp_value.h
new file mode 100644
index 000000000000..164688b15f81
--- /dev/null
+++ b/libcxx/include/__memory/temp_value.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___MEMORY_TEMP_VALUE_H
+#define _LIBCPP___MEMORY_TEMP_VALUE_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory/allocator_traits.h>
+#include <__type_traits/aligned_storage.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Alloc>
+struct __temp_value {
+ typedef allocator_traits<_Alloc> _Traits;
+
+#ifdef _LIBCPP_CXX03_LANG
+ typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
+#else
+ union { _Tp __v; };
+#endif
+ _Alloc &__a;
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp *__addr() {
+#ifdef _LIBCPP_CXX03_LANG
+ return reinterpret_cast<_Tp*>(std::addressof(__v));
+#else
+ return std::addressof(__v);
+#endif
+ }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp & get() { return *__addr(); }
+
+ template<class... _Args>
+ _LIBCPP_NO_CFI
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+ _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
+ }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__temp_value() { _Traits::destroy(__a, __addr()); }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_TEMP_VALUE_H
diff --git a/libcxx/include/__memory/temporary_buffer.h b/libcxx/include/__memory/temporary_buffer.h
index b1f7a126299f..c917f041a014 100644
--- a/libcxx/include/__memory/temporary_buffer.h
+++ b/libcxx/include/__memory/temporary_buffer.h
@@ -23,7 +23,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
{
diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 72b6890c2225..63a45b2ac87b 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -20,11 +20,21 @@
#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <__memory/voidify.h>
+#include <__type_traits/extent.h>
+#include <__type_traits/is_array.h>
#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_trivially_copy_assignable.h>
+#include <__type_traits/is_trivially_copy_constructible.h>
+#include <__type_traits/is_trivially_move_assignable.h>
+#include <__type_traits/is_trivially_move_constructible.h>
+#include <__type_traits/is_unbounded_array.h>
+#include <__type_traits/negation.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_extent.h>
+#include <__utility/exception_guard.h>
#include <__utility/move.h>
#include <__utility/pair.h>
-#include <__utility/transaction.h>
-#include <type_traits>
+#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -64,6 +74,7 @@ __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast,
}
template <class _InputIterator, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI
_ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast,
_ForwardIterator __ofirst) {
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
@@ -282,7 +293,7 @@ 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);
+ return std::__uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n);
}
// uninitialized_move
@@ -410,7 +421,10 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {
_Tp& __array = *__loc;
// If an exception is thrown, destroy what we have constructed so far in reverse order.
- __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
+ __exception_guard __guard([&]() {
+ std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
+ });
+
for (; __i != extent_v<_Tp>; ++__i) {
std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));
}
@@ -447,7 +461,9 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const&
_Tp& __array = *__loc;
// If an exception is thrown, destroy what we have constructed so far in reverse order.
- __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
+ __exception_guard __guard([&]() {
+ std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
+ });
for (; __i != extent_v<_Tp>; ++__i) {
std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
}
@@ -472,7 +488,7 @@ constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it
_BidirIter __begin = __it;
// If an exception is thrown, destroy what we have constructed so far in reverse order.
- __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
+ __exception_guard __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
for (; __n != 0; --__n, ++__it) {
std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);
}
@@ -489,7 +505,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
_BidirIter __begin = __it;
// If an exception is thrown, destroy what we have constructed so far in reverse order.
- __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
+ __exception_guard __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
for (; __n != 0; --__n, ++__it) {
std::__allocator_construct_at(__value_alloc, std::addressof(*__it));
}
@@ -500,7 +516,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
// Destroy all elements in [__first, __last) from left to right using allocator destruction.
template <class _Alloc, class _Iter, class _Sent>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
for (; __first != __last; ++__first)
allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
@@ -509,10 +525,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
template <class _Alloc, class _Iter>
class _AllocatorDestroyRangeReverse {
public:
- _LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
+ _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
: __alloc_(__alloc), __first_(__first), __last_(__last) {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void operator()() const {
std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
}
@@ -527,23 +544,17 @@ private:
// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the
// already copied elements are destroyed in reverse order of their construction.
template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
auto __destruct_first = __first2;
- try {
-#endif
+ auto __guard =
+ std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
while (__first1 != __last1) {
allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);
++__first1;
++__first2;
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
- throw;
- }
-#endif
+ __guard.__complete();
return __first2;
}
@@ -555,12 +566,12 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty
template <class _Alloc,
class _Type,
- class _RawType = typename remove_const<_Type>::type,
+ class _RawType = __remove_const_t<_Type>,
__enable_if_t<
// using _RawType because of the allocator<T const> extension
is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&
__allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type*
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Type*
__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {
// TODO: Remove the const_cast once we drop support for std::allocator<T const>
if (__libcpp_is_constant_evaluated()) {
@@ -581,14 +592,13 @@ __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __la
// Otherwise try to copy all elements. If an exception is thrown the already copied
// elements are destroyed in reverse order of their construction.
template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 __uninitialized_allocator_move_if_noexcept(
_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
static_assert(__is_cpp17_move_insertable<_Alloc>::value,
"The specified type does not meet the requirements of Cpp17MoveInsertable");
-#ifndef _LIBCPP_NO_EXCEPTIONS
auto __destruct_first = __first2;
- try {
-#endif
+ auto __guard =
+ std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
while (__first1 != __last1) {
#ifndef _LIBCPP_NO_EXCEPTIONS
allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));
@@ -598,12 +608,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_alloc
++__first1;
++__first2;
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
- throw;
- }
-#endif
+ __guard.__complete();
return __first2;
}
@@ -621,7 +626,7 @@ template <
class _Type = typename iterator_traits<_Iter1>::value_type,
class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
__allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
if (__libcpp_is_constant_evaluated()) {
while (__first1 != __last1) {
diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index 1de64de30b23..9cdbda8eba40 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -10,16 +10,35 @@
#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H
#define _LIBCPP___MEMORY_UNIQUE_PTR_H
+#include <__compare/compare_three_way.h>
+#include <__compare/compare_three_way_result.h>
+#include <__compare/three_way_comparable.h>
#include <__config>
#include <__functional/hash.h>
#include <__functional/operations.h>
#include <__memory/allocator_traits.h> // __pointer
#include <__memory/auto_ptr.h>
#include <__memory/compressed_pair.h>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/dependent_type.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/remove_extent.h>
+#include <__type_traits/type_identity.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <cstddef>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -37,12 +56,10 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
_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 _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT {
static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");
delete __ptr;
@@ -64,13 +81,11 @@ public:
#endif
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- default_delete(const default_delete<_Up[]>&,
- typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
+ default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- typename _EnableIfConvertible<_Up>::type
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type
operator()(_Up* __ptr) const _NOEXCEPT {
static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
delete[] __ptr;
@@ -172,22 +187,17 @@ public:
_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 = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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)) {
+ template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
+ 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");
}
@@ -197,17 +207,14 @@ public:
_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())) {
- }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <class _Up,
+ class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterConvertible<_Ep> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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)
@@ -220,19 +227,17 @@ public:
: __ptr_(__p.release(), __value_init_tag()) {}
#endif
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ template <class _Up,
+ class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterAssignable<_Ep> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
reset(__u.release());
__ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
return *this;
@@ -255,58 +260,44 @@ public:
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
- _LIBCPP_INLINE_VISIBILITY
- ~unique_ptr() { reset(); }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(nullptr_t) _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
reset();
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
- typename add_lvalue_reference<_Tp>::type
- operator*() const {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const {
return *__ptr_.first();
}
- _LIBCPP_INLINE_VISIBILITY
- pointer operator->() const _NOEXCEPT {
- return __ptr_.first();
- }
- _LIBCPP_INLINE_VISIBILITY
- pointer get() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT {
return __ptr_.first();
}
- _LIBCPP_INLINE_VISIBILITY
- deleter_type& get_deleter() _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
return __ptr_.second();
}
- _LIBCPP_INLINE_VISIBILITY
- const deleter_type& get_deleter() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
return __ptr_.second();
}
- _LIBCPP_INLINE_VISIBILITY
- explicit operator bool() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
return __ptr_.first() != nullptr;
}
- _LIBCPP_INLINE_VISIBILITY
- pointer release() _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
pointer __t = __ptr_.first();
__ptr_.first() = pointer();
return __t;
}
- _LIBCPP_INLINE_VISIBILITY
- void reset(pointer __p = pointer()) _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
__ptr_.swap(__u.__ptr_);
}
};
@@ -394,40 +385,36 @@ public:
_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
+ template <class _Pp,
+ bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy>,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <class _Pp,
+ bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <class _Pp,
+ bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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");
@@ -439,34 +426,27 @@ public:
_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 _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 = _EnableIfDeleterConvertible<_Ep> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ template <class _Up,
+ class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterAssignable<_Ep> >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
reset(__u.release());
__ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
return *this;
@@ -477,90 +457,77 @@ public:
unique_ptr& operator=(unique_ptr const&) = delete;
#endif
public:
- _LIBCPP_INLINE_VISIBILITY
- ~unique_ptr() { reset(); }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(nullptr_t) _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
reset();
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
- typename add_lvalue_reference<_Tp>::type
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp>
operator[](size_t __i) const {
return __ptr_.first()[__i];
}
- _LIBCPP_INLINE_VISIBILITY
- pointer get() const _NOEXCEPT {
- return __ptr_.first();
- }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
- _LIBCPP_INLINE_VISIBILITY
- deleter_type& get_deleter() _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
return __ptr_.second();
}
- _LIBCPP_INLINE_VISIBILITY
- const deleter_type& get_deleter() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
return __ptr_.second();
}
- _LIBCPP_INLINE_VISIBILITY
- explicit operator bool() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
return __ptr_.first() != nullptr;
}
- _LIBCPP_INLINE_VISIBILITY
- pointer release() _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
+ 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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);}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
+ 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();}
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
+operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return __x.get() == __y.get();
+}
+#if _LIBCPP_STD_VER <= 17
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);}
+#endif
template <class _T1, class _D1, class _T2, class _D2>
inline _LIBCPP_INLINE_VISIBILITY
@@ -588,14 +555,26 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
+
+#if _LIBCPP_STD_VER > 17
+template <class _T1, class _D1, class _T2, class _D2>
+requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer,
+ typename unique_ptr<_T2, _D2>::pointer>
+_LIBCPP_HIDE_FROM_ABI
+compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer,
+ typename unique_ptr<_T2, _D2>::pointer>
+operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
+ return compare_three_way()(__x.get(), __y.get());
+}
+#endif
+
template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
-{
- return !__x;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
+operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
+ return !__x;
}
+#if _LIBCPP_STD_VER <= 17
template <class _T1, class _D1>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -619,72 +598,67 @@ operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
{
return static_cast<bool>(__x);
}
+#endif // _LIBCPP_STD_VER <= 17
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);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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());
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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);
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
+operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
+ return !(nullptr < __x);
+}
+
+#if _LIBCPP_STD_VER > 17
+template <class _T1, class _D1>
+ requires three_way_comparable<
+ typename unique_ptr<_T1, _D1>::pointer> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
+ compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>
+operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
+ return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));
}
+#endif
#if _LIBCPP_STD_VER > 11
@@ -706,21 +680,17 @@ 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, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
+make_unique(size_t __n) {
+ typedef __remove_extent_t<_Tp> _Up;
+ return unique_ptr<_Tp>(new _Up[__n]());
}
template<class _Tp, class... _Args>
@@ -729,6 +699,25 @@ template<class _Tp, class... _Args>
#endif // _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
+make_unique_for_overwrite() {
+ return unique_ptr<_Tp>(new _Tp);
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
+make_unique_for_overwrite(size_t __n) {
+ return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]);
+}
+
+template<class _Tp, class... _Args>
+typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete;
+
+#endif // _LIBCPP_STD_VER >= 20
+
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
template <class _Tp, class _Dp>
diff --git a/libcxx/include/__memory/uses_allocator.h b/libcxx/include/__memory/uses_allocator.h
index 4a07a4a52121..fe89704027a0 100644
--- a/libcxx/include/__memory/uses_allocator.h
+++ b/libcxx/include/__memory/uses_allocator.h
@@ -11,8 +11,8 @@
#define _LIBCPP___MEMORY_USES_ALLOCATOR_H
#include <__config>
+#include <__type_traits/is_convertible.h>
#include <cstddef>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__memory/uses_allocator_construction.h b/libcxx/include/__memory/uses_allocator_construction.h
new file mode 100644
index 000000000000..0f63b080daf3
--- /dev/null
+++ b/libcxx/include/__memory/uses_allocator_construction.h
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_CONSTRUCTION_H
+#define _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
+
+#include <__config>
+#include <__memory/construct_at.h>
+#include <__memory/uses_allocator.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
+#include <__utility/declval.h>
+#include <__utility/pair.h>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 17
+
+template <class _Type>
+inline constexpr bool __is_std_pair = false;
+
+template <class _Type1, class _Type2>
+inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;
+
+template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_std_pair<_Type>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept {
+ if constexpr (!uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args...>) {
+ return std::forward_as_tuple(std::forward<_Args>(__args)...);
+ } else if constexpr (uses_allocator_v<_Type, _Alloc> &&
+ is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) {
+ return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...);
+ } else if constexpr (uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args..., const _Alloc&>) {
+ return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc);
+ } else {
+ static_assert(
+ sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible");
+ }
+}
+
+template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
+ const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
+ return std::make_tuple(
+ piecewise_construct,
+ std::apply(
+ [&__alloc](auto&&... __args1) {
+ return std::__uses_allocator_construction_args<typename _Pair::first_type>(
+ __alloc, std::forward<decltype(__args1)>(__args1)...);
+ },
+ std::forward<_Tuple1>(__x)),
+ std::apply(
+ [&__alloc](auto&&... __args2) {
+ return std::__uses_allocator_construction_args<typename _Pair::second_type>(
+ __alloc, std::forward<decltype(__args2)>(__args2)...);
+ },
+ std::forward<_Tuple2>(__y)));
+}
+
+template <class _Pair, class _Alloc, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
+}
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(
+ __alloc,
+ piecewise_construct,
+ std::forward_as_tuple(std::forward<_Up>(__u)),
+ std::forward_as_tuple(std::forward<_Vp>(__v)));
+}
+
+# if _LIBCPP_STD_VER > 20
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(
+ __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
+}
+# endif
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(
+ __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
+}
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(
+ __alloc,
+ piecewise_construct,
+ std::forward_as_tuple(std::get<0>(std::move(__pair))),
+ std::forward_as_tuple(std::get<1>(std::move(__pair))));
+}
+
+# if _LIBCPP_STD_VER > 20
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
+ return std::__uses_allocator_construction_args<_Pair>(
+ __alloc,
+ piecewise_construct,
+ std::forward_as_tuple(std::get<0>(std::move(__pair))),
+ std::forward_as_tuple(std::get<1>(std::move(__pair))));
+}
+# endif
+
+namespace __uses_allocator_detail {
+
+template <class _Ap, class _Bp>
+void __fun(const pair<_Ap, _Bp>&);
+
+template <class _Tp>
+decltype(__uses_allocator_detail::__fun(std::declval<_Tp>()), true_type()) __convertible_to_const_pair_ref_impl(int);
+
+template <class>
+false_type __convertible_to_const_pair_ref_impl(...);
+
+template <class _Tp>
+inline constexpr bool __convertible_to_const_pair_ref =
+ decltype(__uses_allocator_detail::__convertible_to_const_pair_ref_impl<_Tp>(0))::value;
+
+} // namespace __uses_allocator_detail
+
+template <
+ class _Pair,
+ class _Alloc,
+ class _Type,
+ __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept;
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);
+
+template <class _Pair,
+ class _Alloc,
+ class _Type,
+ __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int>>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept {
+ struct __pair_constructor {
+ using _PairMutable = remove_cv_t<_Pair>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(const _PairMutable& __pair) const {
+ return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(_PairMutable&& __pair) const {
+ return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));
+ }
+
+ const _Alloc& __alloc_;
+ _Type& __value_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr operator _PairMutable() const {
+ return __do_construct(std::forward<_Type>(this->__value_));
+ }
+ };
+
+ return std::make_tuple(__pair_constructor{__alloc, __value});
+}
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) {
+ return std::make_from_tuple<_Type>(
+ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
+}
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr _Type*
+__uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) {
+ return std::apply(
+ [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); },
+ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
+}
+
+#endif // _LIBCPP_STD_VER >= 17
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept
+ -> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) {
+ return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...);
+}
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr auto make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args)
+ -> decltype(std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...)) {
+ return /*--*/ std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...);
+}
+
+template <class _Type, class _Alloc, class... _Args>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args)
+ -> decltype(std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...)) {
+ return /*--*/ std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
diff --git a/libcxx/include/__memory/voidify.h b/libcxx/include/__memory/voidify.h
index 3a65c0e83fb7..39e10343f4ca 100644
--- a/libcxx/include/__memory/voidify.h
+++ b/libcxx/include/__memory/voidify.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <typename _Tp>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void* __voidify(_Tp& __from) {
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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)));
}
diff --git a/libcxx/include/__memory_resource/memory_resource.h b/libcxx/include/__memory_resource/memory_resource.h
new file mode 100644
index 000000000000..02fdd081cce5
--- /dev/null
+++ b/libcxx/include/__memory_resource/memory_resource.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___MEMORY_RESOURCE_MEMORY_RESOURCE_H
+#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.res.class]
+
+class _LIBCPP_TYPE_VIS memory_resource {
+ static const size_t __max_align = alignof(max_align_t);
+
+public:
+ virtual ~memory_resource();
+
+ _LIBCPP_NODISCARD_AFTER_CXX17
+ [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] _LIBCPP_HIDE_FROM_ABI void*
+ allocate(size_t __bytes, size_t __align = __max_align) {
+ return do_allocate(__bytes, __align);
+ }
+
+ [[__gnu__::__nonnull__]] _LIBCPP_HIDE_FROM_ABI void
+ deallocate(void* __p, size_t __bytes, size_t __align = __max_align) {
+ do_deallocate(__p, __bytes, __align);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI bool is_equal(const memory_resource& __other) const noexcept { return do_is_equal(__other); }
+
+private:
+ virtual void* do_allocate(size_t, size_t) = 0;
+ virtual void do_deallocate(void*, size_t, size_t) = 0;
+ virtual bool do_is_equal(memory_resource const&) const noexcept = 0;
+};
+
+// [mem.res.eq]
+
+inline _LIBCPP_HIDE_FROM_ABI bool operator==(const memory_resource& __lhs, const memory_resource& __rhs) noexcept {
+ return &__lhs == &__rhs || __lhs.is_equal(__rhs);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept {
+ return !(__lhs == __rhs);
+}
+
+// [mem.res.global]
+
+[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* get_default_resource() noexcept;
+[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* set_default_resource(memory_resource*) noexcept;
+[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* new_delete_resource() noexcept;
+[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* null_memory_resource() noexcept;
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
diff --git a/libcxx/include/__memory_resource/monotonic_buffer_resource.h b/libcxx/include/__memory_resource/monotonic_buffer_resource.h
new file mode 100644
index 000000000000..5b0d2462582e
--- /dev/null
+++ b/libcxx/include/__memory_resource/monotonic_buffer_resource.h
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
+#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory_resource/memory_resource.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.res.monotonic.buffer]
+
+class _LIBCPP_TYPE_VIS monotonic_buffer_resource : public memory_resource {
+ static const size_t __default_buffer_capacity = 1024;
+ static const size_t __default_buffer_alignment = 16;
+
+ struct __chunk_footer {
+ __chunk_footer* __next_;
+ char* __start_;
+ char* __cur_;
+ size_t __align_;
+ size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); }
+ void* __try_allocate_from_chunk(size_t, size_t);
+ };
+
+ struct __initial_descriptor {
+ char* __start_;
+ char* __cur_;
+ union {
+ char* __end_;
+ size_t __size_;
+ };
+ void* __try_allocate_from_chunk(size_t, size_t);
+ };
+
+public:
+ _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource()
+ : monotonic_buffer_resource(nullptr, __default_buffer_capacity, get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit monotonic_buffer_resource(size_t __initial_size)
+ : monotonic_buffer_resource(nullptr, __initial_size, get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(void* __buffer, size_t __buffer_size)
+ : monotonic_buffer_resource(__buffer, __buffer_size, get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit monotonic_buffer_resource(memory_resource* __upstream)
+ : monotonic_buffer_resource(nullptr, __default_buffer_capacity, __upstream) {}
+
+ _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(size_t __initial_size, memory_resource* __upstream)
+ : monotonic_buffer_resource(nullptr, __initial_size, __upstream) {}
+
+ _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(void* __buffer, size_t __buffer_size, memory_resource* __upstream)
+ : __res_(__upstream) {
+ __initial_.__start_ = static_cast<char*>(__buffer);
+ if (__buffer != nullptr) {
+ __initial_.__cur_ = static_cast<char*>(__buffer) + __buffer_size;
+ __initial_.__end_ = static_cast<char*>(__buffer) + __buffer_size;
+ } else {
+ __initial_.__cur_ = nullptr;
+ __initial_.__size_ = __buffer_size;
+ }
+ __chunks_ = nullptr;
+ }
+
+ monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~monotonic_buffer_resource() override { release(); }
+
+ monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI void release() {
+ if (__initial_.__start_ != nullptr)
+ __initial_.__cur_ = __initial_.__end_;
+ while (__chunks_ != nullptr) {
+ __chunk_footer* __next = __chunks_->__next_;
+ __res_->deallocate(__chunks_->__start_, __chunks_->__allocation_size(), __chunks_->__align_);
+ __chunks_ = __next;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; }
+
+protected:
+ void* do_allocate(size_t __bytes, size_t __alignment) override; // key function
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void*, size_t, size_t) override {}
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool do_is_equal(const memory_resource& __other) const _NOEXCEPT override {
+ return this == std::addressof(__other);
+ }
+
+private:
+ __initial_descriptor __initial_;
+ __chunk_footer* __chunks_;
+ memory_resource* __res_;
+};
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
diff --git a/libcxx/include/__memory_resource/polymorphic_allocator.h b/libcxx/include/__memory_resource/polymorphic_allocator.h
new file mode 100644
index 000000000000..2489502bcdaf
--- /dev/null
+++ b/libcxx/include/__memory_resource/polymorphic_allocator.h
@@ -0,0 +1,224 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_RESOURCE_POLYMORPHIC_ALLOCATOR_H
+#define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
+
+#include <__assert>
+#include <__config>
+#include <__memory_resource/memory_resource.h>
+#include <__utility/exception_guard.h>
+#include <cstddef>
+#include <limits>
+#include <new>
+#include <stdexcept>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.poly.allocator.class]
+
+template <class _ValueType
+# if _LIBCPP_STD_VER >= 20
+ = byte
+# endif
+ >
+class _LIBCPP_TEMPLATE_VIS polymorphic_allocator {
+
+public:
+ using value_type = _ValueType;
+
+ // [mem.poly.allocator.ctor]
+
+ _LIBCPP_HIDE_FROM_ABI polymorphic_allocator() noexcept : __res_(std::pmr::get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(memory_resource* __r) noexcept : __res_(__r) {}
+
+ polymorphic_allocator(const polymorphic_allocator&) = default;
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(const polymorphic_allocator<_Tp>& __other) noexcept
+ : __res_(__other.resource()) {}
+
+ polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
+
+ // [mem.poly.allocator.mem]
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {
+ if (__n > __max_size()) {
+ __throw_bad_array_new_length();
+ }
+ return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void deallocate(_ValueType* __p, size_t __n) {
+ _LIBCPP_ASSERT(__n <= __max_size(), "deallocate called for size which exceeds max_size()");
+ __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
+ }
+
+# if _LIBCPP_STD_VER >= 20
+
+ [[nodiscard]] [[using __gnu__: __alloc_size__(2), __alloc_align__(3)]] void*
+ allocate_bytes(size_t __nbytes, size_t __alignment = alignof(max_align_t)) {
+ return __res_->allocate(__nbytes, __alignment);
+ }
+
+ void deallocate_bytes(void* __ptr, size_t __nbytes, size_t __alignment = alignof(max_align_t)) {
+ __res_->deallocate(__ptr, __nbytes, __alignment);
+ }
+
+ template <class _Type>
+ [[nodiscard]] _Type* allocate_object(size_t __n = 1) {
+ if (numeric_limits<size_t>::max() / sizeof(_Type) < __n)
+ std::__throw_bad_array_new_length();
+ return static_cast<_Type*>(allocate_bytes(__n * sizeof(_Type), alignof(_Type)));
+ }
+
+ template <class _Type>
+ void deallocate_object(_Type* __ptr, size_t __n = 1) {
+ deallocate_bytes(__ptr, __n * sizeof(_Type), alignof(_Type));
+ }
+
+ template <class _Type, class... _CtorArgs>
+ [[nodiscard]] _Type* new_object(_CtorArgs&&... __ctor_args) {
+ _Type* __ptr = allocate_object<_Type>();
+ __exception_guard __guard([&] { deallocate_object(__ptr); });
+ construct(__ptr, std::forward<_CtorArgs>(__ctor_args)...);
+ __guard.__complete();
+ return __ptr;
+ }
+
+ template <class _Type>
+ void delete_object(_Type* __ptr) {
+ destroy(__ptr);
+ deallocate_object(__ptr);
+ }
+
+# endif // _LIBCPP_STD_VER >= 20
+
+ template <class _Tp, class... _Ts>
+ _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Ts&&... __args) {
+ std::__user_alloc_construct_impl(
+ typename __uses_alloc_ctor<_Tp, polymorphic_allocator&, _Ts...>::type(),
+ __p,
+ *this,
+ std::forward<_Ts>(__args)...);
+ }
+
+ template <class _T1, class _T2, class... _Args1, class... _Args2>
+ _LIBCPP_HIDE_FROM_ABI void
+ construct(pair<_T1, _T2>* __p, piecewise_construct_t, tuple<_Args1...> __x, tuple<_Args2...> __y) {
+ ::new ((void*)__p) pair<_T1, _T2>(
+ piecewise_construct,
+ __transform_tuple(typename __uses_alloc_ctor< _T1, polymorphic_allocator&, _Args1... >::type(),
+ std::move(__x),
+ typename __make_tuple_indices<sizeof...(_Args1)>::type{}),
+ __transform_tuple(typename __uses_alloc_ctor< _T2, polymorphic_allocator&, _Args2... >::type(),
+ std::move(__y),
+ typename __make_tuple_indices<sizeof...(_Args2)>::type{}));
+ }
+
+ template <class _T1, class _T2>
+ _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) {
+ construct(__p, piecewise_construct, tuple<>(), tuple<>());
+ }
+
+ template <class _T1, class _T2, class _Up, class _Vp>
+ _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v) {
+ construct(__p,
+ piecewise_construct,
+ std::forward_as_tuple(std::forward<_Up>(__u)),
+ std::forward_as_tuple(std::forward<_Vp>(__v)));
+ }
+
+ template <class _T1, class _T2, class _U1, class _U2>
+ _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_U1, _U2>& __pr) {
+ construct(__p, piecewise_construct, std::forward_as_tuple(__pr.first), std::forward_as_tuple(__pr.second));
+ }
+
+ template <class _T1, class _T2, class _U1, class _U2>
+ _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_U1, _U2>&& __pr) {
+ construct(__p,
+ piecewise_construct,
+ std::forward_as_tuple(std::forward<_U1>(__pr.first)),
+ std::forward_as_tuple(std::forward<_U2>(__pr.second)));
+ }
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {
+ __p->~_Tp();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI polymorphic_allocator select_on_container_copy_construction() const noexcept {
+ return polymorphic_allocator();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; }
+
+private:
+ template <class... _Args, size_t... _Is>
+ _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>
+ __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
+ return std::forward_as_tuple(std::get<_Is>(std::move(__t))...);
+ }
+
+ template <class... _Args, size_t... _Is>
+ _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>
+ __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
+ using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
+ return _Tup(allocator_arg, *this, std::get<_Is>(std::move(__t))...);
+ }
+
+ template <class... _Args, size_t... _Is>
+ _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., polymorphic_allocator&>
+ __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
+ using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
+ return _Tup(std::get<_Is>(std::move(__t))..., *this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI size_t __max_size() const noexcept {
+ return numeric_limits<size_t>::max() / sizeof(value_type);
+ }
+
+ memory_resource* __res_;
+};
+
+// [mem.poly.allocator.eq]
+
+template <class _Tp, class _Up>
+inline _LIBCPP_HIDE_FROM_ABI bool
+operator==(const polymorphic_allocator<_Tp>& __lhs, const polymorphic_allocator<_Up>& __rhs) noexcept {
+ return *__lhs.resource() == *__rhs.resource();
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_HIDE_FROM_ABI bool
+operator!=(const polymorphic_allocator<_Tp>& __lhs, const polymorphic_allocator<_Up>& __rhs) noexcept {
+ return !(__lhs == __rhs);
+}
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
diff --git a/libcxx/include/__memory_resource/pool_options.h b/libcxx/include/__memory_resource/pool_options.h
new file mode 100644
index 000000000000..11585a0e3bc8
--- /dev/null
+++ b/libcxx/include/__memory_resource/pool_options.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___MEMORY_RESOURCE_POOL_OPTIONS_H
+#define _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.res.pool.options]
+
+struct _LIBCPP_TYPE_VIS pool_options {
+ size_t max_blocks_per_chunk = 0;
+ size_t largest_required_pool_block = 0;
+};
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
diff --git a/libcxx/include/__memory_resource/synchronized_pool_resource.h b/libcxx/include/__memory_resource/synchronized_pool_resource.h
new file mode 100644
index 000000000000..1877147ca16f
--- /dev/null
+++ b/libcxx/include/__memory_resource/synchronized_pool_resource.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___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
+#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
+
+#include <__config>
+#include <__memory_resource/memory_resource.h>
+#include <__memory_resource/pool_options.h>
+#include <__memory_resource/unsynchronized_pool_resource.h>
+#include <cstddef>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+# include <mutex>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.res.pool.overview]
+
+class _LIBCPP_TYPE_VIS synchronized_pool_resource : public memory_resource {
+public:
+ _LIBCPP_HIDE_FROM_ABI synchronized_pool_resource(const pool_options& __opts, memory_resource* __upstream)
+ : __unsync_(__opts, __upstream) {}
+
+ _LIBCPP_HIDE_FROM_ABI synchronized_pool_resource()
+ : synchronized_pool_resource(pool_options(), get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit synchronized_pool_resource(memory_resource* __upstream)
+ : synchronized_pool_resource(pool_options(), __upstream) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit synchronized_pool_resource(const pool_options& __opts)
+ : synchronized_pool_resource(__opts, get_default_resource()) {}
+
+ synchronized_pool_resource(const synchronized_pool_resource&) = delete;
+
+ ~synchronized_pool_resource() override = default;
+
+ synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI void release() {
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+ unique_lock<mutex> __lk(__mut_);
+# endif
+ __unsync_.release();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __unsync_.upstream_resource(); }
+
+ _LIBCPP_HIDE_FROM_ABI pool_options options() const { return __unsync_.options(); }
+
+protected:
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override {
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+ unique_lock<mutex> __lk(__mut_);
+# endif
+ return __unsync_.allocate(__bytes, __align);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __p, size_t __bytes, size_t __align) override {
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+ unique_lock<mutex> __lk(__mut_);
+# endif
+ return __unsync_.deallocate(__p, __bytes, __align);
+ }
+
+ bool do_is_equal(const memory_resource& __other) const noexcept override; // key function
+
+private:
+# if !defined(_LIBCPP_HAS_NO_THREADS)
+ mutex __mut_;
+# endif
+ unsynchronized_pool_resource __unsync_;
+};
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
diff --git a/libcxx/include/__memory_resource/unsynchronized_pool_resource.h b/libcxx/include/__memory_resource/unsynchronized_pool_resource.h
new file mode 100644
index 000000000000..91d38aac0df0
--- /dev/null
+++ b/libcxx/include/__memory_resource/unsynchronized_pool_resource.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___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
+#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
+
+#include <__config>
+#include <__memory_resource/memory_resource.h>
+#include <__memory_resource/pool_options.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace pmr {
+
+// [mem.res.pool.overview]
+
+class _LIBCPP_TYPE_VIS unsynchronized_pool_resource : public memory_resource {
+ class __fixed_pool;
+
+ class __adhoc_pool {
+ struct __chunk_footer;
+ __chunk_footer* __first_;
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI explicit __adhoc_pool() : __first_(nullptr) {}
+
+ void __release_ptr(memory_resource* __upstream);
+ void* __do_allocate(memory_resource* __upstream, size_t __bytes, size_t __align);
+ void __do_deallocate(memory_resource* __upstream, void* __p, size_t __bytes, size_t __align);
+ };
+
+ static const size_t __min_blocks_per_chunk = 16;
+ static const size_t __min_bytes_per_chunk = 1024;
+ static const size_t __max_blocks_per_chunk = (size_t(1) << 20);
+ static const size_t __max_bytes_per_chunk = (size_t(1) << 30);
+
+ static const int __log2_smallest_block_size = 3;
+ static const size_t __smallest_block_size = 8;
+ static const size_t __default_largest_block_size = (size_t(1) << 20);
+ static const size_t __max_largest_block_size = (size_t(1) << 30);
+
+ size_t __pool_block_size(int __i) const;
+ int __log2_pool_block_size(int __i) const;
+ int __pool_index(size_t __bytes, size_t __align) const;
+
+public:
+ unsynchronized_pool_resource(const pool_options& __opts, memory_resource* __upstream);
+
+ _LIBCPP_HIDE_FROM_ABI unsynchronized_pool_resource()
+ : unsynchronized_pool_resource(pool_options(), get_default_resource()) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit unsynchronized_pool_resource(memory_resource* __upstream)
+ : unsynchronized_pool_resource(pool_options(), __upstream) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit unsynchronized_pool_resource(const pool_options& __opts)
+ : unsynchronized_pool_resource(__opts, get_default_resource()) {}
+
+ unsynchronized_pool_resource(const unsynchronized_pool_resource&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~unsynchronized_pool_resource() override { release(); }
+
+ unsynchronized_pool_resource& operator=(const unsynchronized_pool_resource&) = delete;
+
+ void release();
+
+ _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; }
+
+ [[__gnu__::__pure__]] pool_options options() const;
+
+protected:
+ void* do_allocate(size_t __bytes, size_t __align) override; // key function
+
+ void do_deallocate(void* __p, size_t __bytes, size_t __align) override;
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool do_is_equal(const memory_resource& __other) const _NOEXCEPT override {
+ return &__other == this;
+ }
+
+private:
+ memory_resource* __res_;
+ __adhoc_pool __adhoc_pool_;
+ __fixed_pool* __fixed_pools_;
+ int __num_fixed_pools_;
+ uint32_t __options_max_blocks_per_chunk_;
+};
+
+} // namespace pmr
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 14
+
+#endif // _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index ac0d090b7d19..82d9fa6ecbac 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -103,6 +103,7 @@ private:
lock_guard(lock_guard const&) = delete;
lock_guard& operator=(lock_guard const&) = delete;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard);
template <class _Mutex>
class _LIBCPP_TEMPLATE_VIS unique_lock
@@ -195,6 +196,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
template <class _Mutex>
void
diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle
index 71309be62f3c..bc49272b9f1c 100644
--- a/libcxx/include/__node_handle
+++ b/libcxx/include/__node_handle
@@ -60,7 +60,8 @@ public:
#include <__assert>
#include <__config>
-#include <memory>
+#include <__memory/allocator_traits.h>
+#include <__memory/pointer_traits.h>
#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -90,8 +91,8 @@ class _LIBCPP_TEMPLATE_VIS __basic_node_handle
_NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,
- _NodeType>::type
+ typedef __rebind_pointer_t<typename __alloc_traits::void_pointer,
+ _NodeType>
__node_pointer_type;
public:
diff --git a/libcxx/include/__numeric/accumulate.h b/libcxx/include/__numeric/accumulate.h
index fa759872ce77..81fc0c2943d9 100644
--- a/libcxx/include/__numeric/accumulate.h
+++ b/libcxx/include/__numeric/accumulate.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
@@ -34,7 +34,7 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
}
template <class _InputIterator, class _Tp, class _BinaryOperation>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
{
diff --git a/libcxx/include/__numeric/adjacent_difference.h b/libcxx/include/__numeric/adjacent_difference.h
index 5c712ecdf77d..57e2f5b2803f 100644
--- a/libcxx/include/__numeric/adjacent_difference.h
+++ b/libcxx/include/__numeric/adjacent_difference.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
@@ -44,7 +44,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
diff --git a/libcxx/include/__numeric/exclusive_scan.h b/libcxx/include/__numeric/exclusive_scan.h
index c0c89b38805d..d02e126b5317 100644
--- a/libcxx/include/__numeric/exclusive_scan.h
+++ b/libcxx/include/__numeric/exclusive_scan.h
@@ -23,7 +23,7 @@ _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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {
if (__first != __last) {
_Tp __tmp(__b(__init, *__first));
@@ -41,7 +41,7 @@ exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
}
template <class _InputIterator, class _OutputIterator, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {
return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
}
diff --git a/libcxx/include/__numeric/gcd_lcm.h b/libcxx/include/__numeric/gcd_lcm.h
index 9a53a001f211..5a3f81b695e2 100644
--- a/libcxx/include/__numeric/gcd_lcm.h
+++ b/libcxx/include/__numeric/gcd_lcm.h
@@ -12,8 +12,12 @@
#include <__assert>
#include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/make_unsigned.h>
#include <limits>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -60,8 +64,8 @@ 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" );
+ static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to gcd cannot be bool" );
+ static_assert((!is_same<__remove_cv_t<_Up>, 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(
@@ -75,8 +79,8 @@ 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" );
+ static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to lcm cannot be bool" );
+ static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to lcm cannot be bool" );
if (__m == 0 || __n == 0)
return 0;
diff --git a/libcxx/include/__numeric/inclusive_scan.h b/libcxx/include/__numeric/inclusive_scan.h
index a6b005075835..e5bf5ac5b7d5 100644
--- a/libcxx/include/__numeric/inclusive_scan.h
+++ b/libcxx/include/__numeric/inclusive_scan.h
@@ -24,7 +24,7 @@ _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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {
for (; __first != __last; ++__first, (void)++__result) {
__init = __b(__init, *__first);
@@ -34,7 +34,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {
if (__first != __last) {
typename iterator_traits<_InputIterator>::value_type __init = *__first;
@@ -47,7 +47,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
}
template <class _InputIterator, class _OutputIterator>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator inclusive_scan(_InputIterator __first,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first,
_InputIterator __last,
_OutputIterator __result) {
return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
diff --git a/libcxx/include/__numeric/inner_product.h b/libcxx/include/__numeric/inner_product.h
index 6fe18bb2b19e..e3d68c04c28b 100644
--- a/libcxx/include/__numeric/inner_product.h
+++ b/libcxx/include/__numeric/inner_product.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator1, class _InputIterator2, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
{
@@ -34,7 +34,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
}
template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
diff --git a/libcxx/include/__numeric/iota.h b/libcxx/include/__numeric/iota.h
index b7127a11cb75..eacdc5b6ec7f 100644
--- a/libcxx/include/__numeric/iota.h
+++ b/libcxx/include/__numeric/iota.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
{
diff --git a/libcxx/include/__numeric/midpoint.h b/libcxx/include/__numeric/midpoint.h
index 668030c46bcb..bac3642cbd2a 100644
--- a/libcxx/include/__numeric/midpoint.h
+++ b/libcxx/include/__numeric/midpoint.h
@@ -11,8 +11,18 @@
#define _LIBCPP___NUMERIC_MIDPOINT_H
#include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_null_pointer.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_pointer.h>
+#include <cstddef>
#include <limits>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -55,12 +65,12 @@ midpoint(_TPtr __a, _TPtr __b) noexcept
template <typename _Tp>
-constexpr int __sign(_Tp __val) {
+_LIBCPP_HIDE_FROM_ABI 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; }
+_LIBCPP_HIDE_FROM_ABI constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; }
template <class _Fp>
_LIBCPP_INLINE_VISIBILITY constexpr
@@ -69,10 +79,10 @@ 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
+ return std::__fp_abs(__a) <= __hi && std::__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
+ std::__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
+ std::__fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
__a/2 + __b/2; // otherwise correctly rounded
}
diff --git a/libcxx/include/__numeric/partial_sum.h b/libcxx/include/__numeric/partial_sum.h
index 9acee3afc2b0..97cca582c070 100644
--- a/libcxx/include/__numeric/partial_sum.h
+++ b/libcxx/include/__numeric/partial_sum.h
@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
@@ -43,7 +43,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
diff --git a/libcxx/include/__numeric/reduce.h b/libcxx/include/__numeric/reduce.h
index 90e4d238d868..b64df05bc80e 100644
--- a/libcxx/include/__numeric/reduce.h
+++ b/libcxx/include/__numeric/reduce.h
@@ -22,7 +22,7 @@ _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,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last,
_Tp __init, _BinaryOp __b) {
for (; __first != __last; ++__first)
__init = __b(__init, *__first);
@@ -30,13 +30,13 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterato
}
template <class _InputIterator, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type
reduce(_InputIterator __first, _InputIterator __last) {
return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});
}
diff --git a/libcxx/include/__numeric/transform_exclusive_scan.h b/libcxx/include/__numeric/transform_exclusive_scan.h
index 45b3077f6649..afbcdb8db836 100644
--- a/libcxx/include/__numeric/transform_exclusive_scan.h
+++ b/libcxx/include/__numeric/transform_exclusive_scan.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp,
class _BinaryOp, class _UnaryOp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Tp __init,
diff --git a/libcxx/include/__numeric/transform_inclusive_scan.h b/libcxx/include/__numeric/transform_inclusive_scan.h
index b0d4ab5a88fd..c050041bc153 100644
--- a/libcxx/include/__numeric/transform_inclusive_scan.h
+++ b/libcxx/include/__numeric/transform_inclusive_scan.h
@@ -22,7 +22,7 @@ _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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
@@ -36,7 +36,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
diff --git a/libcxx/include/__numeric/transform_reduce.h b/libcxx/include/__numeric/transform_reduce.h
index da5a77988c38..d997521a95e6 100644
--- a/libcxx/include/__numeric/transform_reduce.h
+++ b/libcxx/include/__numeric/transform_reduce.h
@@ -22,7 +22,7 @@ _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,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator __first,
_InputIterator __last, _Tp __init,
_BinaryOp __b, _UnaryOp __u) {
for (; __first != __last; ++__first)
@@ -31,7 +31,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
}
template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init,
_BinaryOp1 __b1, _BinaryOp2 __b2) {
@@ -41,7 +41,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
}
template <class _InputIterator1, class _InputIterator2, class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1,
_InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init) {
return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(),
diff --git a/libcxx/include/__random/bernoulli_distribution.h b/libcxx/include/__random/bernoulli_distribution.h
index e97d53f5a421..e38d3dfb894a 100644
--- a/libcxx/include/__random/bernoulli_distribution.h
+++ b/libcxx/include/__random/bernoulli_distribution.h
@@ -110,7 +110,7 @@ bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
{
__save_flags<_CharT, _Traits> __lx(__os);
@@ -123,7 +123,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& _
}
template <class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
{
typedef bernoulli_distribution _Eng;
diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index af60fa2a38e0..7b0f055d5068 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -133,9 +133,9 @@ binomial_distribution<_IntType>::param_type::param_type(result_type __t, double
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_) +
+ __pr_ = _VSTD::exp(std::__libcpp_lgamma(__t_ + 1.) -
+ std::__libcpp_lgamma(__r0_ + 1.) -
+ std::__libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
(__t_ - __r0_) * _VSTD::log(1 - __p_));
__odds_ratio_ = __p_ / (1 - __p_);
}
@@ -189,7 +189,7 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
}
template <class _CharT, class _Traits, class _IntType>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const binomial_distribution<_IntType>& __x)
{
@@ -203,7 +203,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IntType>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
binomial_distribution<_IntType>& __x)
{
diff --git a/libcxx/include/__random/cauchy_distribution.h b/libcxx/include/__random/cauchy_distribution.h
index 5bc44ee8dd4c..2fda6b538376 100644
--- a/libcxx/include/__random/cauchy_distribution.h
+++ b/libcxx/include/__random/cauchy_distribution.h
@@ -124,7 +124,7 @@ cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const cauchy_distribution<_RT>& __x)
{
@@ -139,7 +139,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
cauchy_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/chi_squared_distribution.h b/libcxx/include/__random/chi_squared_distribution.h
index b98488c20d28..f2922b64dd6c 100644
--- a/libcxx/include/__random/chi_squared_distribution.h
+++ b/libcxx/include/__random/chi_squared_distribution.h
@@ -107,7 +107,7 @@ public:
};
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const chi_squared_distribution<_RT>& __x)
{
@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
chi_squared_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/discard_block_engine.h b/libcxx/include/__random/discard_block_engine.h
index c58d66b58869..db33623d9485 100644
--- a/libcxx/include/__random/discard_block_engine.h
+++ b/libcxx/include/__random/discard_block_engine.h
@@ -12,8 +12,8 @@
#include <__config>
#include <__random/is_seed_sequence.h>
#include <__utility/move.h>
-#include <climits>
#include <iosfwd>
+#include <limits>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -33,7 +33,9 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine
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");
+#ifndef _LIBCPP_CXX03_LANG // numeric_limits::max() is not constexpr in C++03
+ static_assert(__r <= numeric_limits<int>::max(), "discard_block_engine invalid parameters");
+#endif
public:
// types
typedef typename _Engine::result_type result_type;
@@ -164,7 +166,7 @@ operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
template <class _CharT, class _Traits,
class _Eng, size_t _Pp, size_t _Rp>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const discard_block_engine<_Eng, _Pp, _Rp>& __x)
{
@@ -178,7 +180,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
template <class _CharT, class _Traits,
class _Eng, size_t _Pp, size_t _Rp>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
discard_block_engine<_Eng, _Pp, _Rp>& __x)
{
diff --git a/libcxx/include/__random/discrete_distribution.h b/libcxx/include/__random/discrete_distribution.h
index 8dc63c0e98b4..03f49ba87239 100644
--- a/libcxx/include/__random/discrete_distribution.h
+++ b/libcxx/include/__random/discrete_distribution.h
@@ -221,7 +221,7 @@ discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits, class _IT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const discrete_distribution<_IT>& __x)
{
@@ -239,7 +239,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
discrete_distribution<_IT>& __x)
{
diff --git a/libcxx/include/__random/exponential_distribution.h b/libcxx/include/__random/exponential_distribution.h
index 1c9e9e0d9ef1..8edf1ac3f68c 100644
--- a/libcxx/include/__random/exponential_distribution.h
+++ b/libcxx/include/__random/exponential_distribution.h
@@ -121,7 +121,7 @@ exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __
}
template <class _CharT, class _Traits, class _RealType>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const exponential_distribution<_RealType>& __x)
{
@@ -133,7 +133,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RealType>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
exponential_distribution<_RealType>& __x)
{
diff --git a/libcxx/include/__random/extreme_value_distribution.h b/libcxx/include/__random/extreme_value_distribution.h
index ba30aa5b88c3..b3cba392490b 100644
--- a/libcxx/include/__random/extreme_value_distribution.h
+++ b/libcxx/include/__random/extreme_value_distribution.h
@@ -123,7 +123,7 @@ extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type&
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const extreme_value_distribution<_RT>& __x)
{
@@ -138,7 +138,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
extreme_value_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/fisher_f_distribution.h b/libcxx/include/__random/fisher_f_distribution.h
index 60c7f28c0bb0..b5479acb47c6 100644
--- a/libcxx/include/__random/fisher_f_distribution.h
+++ b/libcxx/include/__random/fisher_f_distribution.h
@@ -122,7 +122,7 @@ fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const fisher_f_distribution<_RT>& __x)
{
@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
fisher_f_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/gamma_distribution.h b/libcxx/include/__random/gamma_distribution.h
index 986d79b67aa3..0d7fc3f82800 100644
--- a/libcxx/include/__random/gamma_distribution.h
+++ b/libcxx/include/__random/gamma_distribution.h
@@ -175,7 +175,7 @@ gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const gamma_distribution<_RT>& __x)
{
@@ -190,7 +190,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
gamma_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/generate_canonical.h b/libcxx/include/__random/generate_canonical.h
index 84efa7803c94..5fada6df5903 100644
--- a/libcxx/include/__random/generate_canonical.h
+++ b/libcxx/include/__random/generate_canonical.h
@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// generate_canonical
template<class _RealType, size_t __bits, class _URNG>
-_RealType
+_LIBCPP_HIDE_FROM_ABI _RealType
generate_canonical(_URNG& __g)
{
const size_t _Dt = numeric_limits<_RealType>::digits;
diff --git a/libcxx/include/__random/geometric_distribution.h b/libcxx/include/__random/geometric_distribution.h
index 751cf7860e66..8f9bdffc7c20 100644
--- a/libcxx/include/__random/geometric_distribution.h
+++ b/libcxx/include/__random/geometric_distribution.h
@@ -108,7 +108,7 @@ public:
};
template <class _CharT, class _Traits, class _IntType>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const geometric_distribution<_IntType>& __x)
{
@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IntType>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
geometric_distribution<_IntType>& __x)
{
diff --git a/libcxx/include/__random/independent_bits_engine.h b/libcxx/include/__random/independent_bits_engine.h
index e80d6eec49cb..151492a81bd0 100644
--- a/libcxx/include/__random/independent_bits_engine.h
+++ b/libcxx/include/__random/independent_bits_engine.h
@@ -51,12 +51,8 @@ private:
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;
+ typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
+ _Working_result_type;
#ifdef _LIBCPP_CXX03_LANG
static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
+ _Working_result_type(1);
@@ -244,7 +240,7 @@ operator!=(
template <class _CharT, class _Traits,
class _Eng, size_t _Wp, class _UInt>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const independent_bits_engine<_Eng, _Wp, _UInt>& __x)
{
@@ -253,7 +249,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
template <class _CharT, class _Traits,
class _Eng, size_t _Wp, class _UInt>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
independent_bits_engine<_Eng, _Wp, _UInt>& __x)
{
diff --git a/libcxx/include/__random/is_seed_sequence.h b/libcxx/include/__random/is_seed_sequence.h
index a6832f51c1ee..3c82b2790b03 100644
--- a/libcxx/include/__random/is_seed_sequence.h
+++ b/libcxx/include/__random/is_seed_sequence.h
@@ -23,7 +23,7 @@ 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;
+ !is_same<__remove_cv_t<_Sseq>, _Engine>::value;
};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__random/is_valid.h b/libcxx/include/__random/is_valid.h
index be3b61b8dc01..1d65de00fbb6 100644
--- a/libcxx/include/__random/is_valid.h
+++ b/libcxx/include/__random/is_valid.h
@@ -53,7 +53,7 @@ template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {};
template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
is_unsigned<typename _Gp::result_type>::value &&
- _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value
+ _IsSame<decltype(std::declval<_Gp&>()()), typename _Gp::result_type>::value
> > : true_type {};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__random/linear_congruential_engine.h b/libcxx/include/__random/linear_congruential_engine.h
index 42b40813e0ac..0d91f14120b6 100644
--- a/libcxx/include/__random/linear_congruential_engine.h
+++ b/libcxx/include/__random/linear_congruential_engine.h
@@ -198,7 +198,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
template <class _CharT, class _Traits,
class _Up, _Up _Ap, _Up _Cp, _Up _Np>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
@@ -372,7 +372,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
template <class _CharT, class _Traits,
class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
{
diff --git a/libcxx/include/__random/log2.h b/libcxx/include/__random/log2.h
index b077d211cefa..72bf0759eeac 100644
--- a/libcxx/include/__random/log2.h
+++ b/libcxx/include/__random/log2.h
@@ -58,15 +58,12 @@ 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,
+ __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>,
#else
unsigned long long,
#endif // _LIBCPP_HAS_NO_INT128
- _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
+ _Xp,
+ sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h
index 8bceac05dce9..3a58e311b001 100644
--- a/libcxx/include/__random/mersenne_twister_engine.h
+++ b/libcxx/include/__random/mersenne_twister_engine.h
@@ -36,7 +36,7 @@ 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
+_LIBCPP_HIDE_FROM_ABI 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,
@@ -56,7 +56,7 @@ 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>&
+_LIBCPP_HIDE_FROM_ABI 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);
@@ -65,7 +65,7 @@ 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>&
+_LIBCPP_HIDE_FROM_ABI 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);
@@ -416,7 +416,7 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
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
+_LIBCPP_HIDE_FROM_ABI 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,
@@ -474,7 +474,7 @@ 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>&
+_LIBCPP_HIDE_FROM_ABI 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)
@@ -496,7 +496,7 @@ 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>&
+_LIBCPP_HIDE_FROM_ABI 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)
diff --git a/libcxx/include/__random/negative_binomial_distribution.h b/libcxx/include/__random/negative_binomial_distribution.h
index 90d3f0178914..333c9350cd72 100644
--- a/libcxx/include/__random/negative_binomial_distribution.h
+++ b/libcxx/include/__random/negative_binomial_distribution.h
@@ -144,7 +144,7 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_
}
template <class _CharT, class _Traits, class _IntType>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const negative_binomial_distribution<_IntType>& __x)
{
@@ -158,7 +158,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IntType>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
negative_binomial_distribution<_IntType>& __x)
{
diff --git a/libcxx/include/__random/normal_distribution.h b/libcxx/include/__random/normal_distribution.h
index 0431df927200..b2ed47e6af46 100644
--- a/libcxx/include/__random/normal_distribution.h
+++ b/libcxx/include/__random/normal_distribution.h
@@ -58,8 +58,8 @@ public:
private:
param_type __p_;
- result_type _V_;
- bool _V_hot_;
+ result_type __v_;
+ bool __v_hot_;
public:
// constructors and reset functions
@@ -68,18 +68,18 @@ public:
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) {}
+ : __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) {}
+ : __p_(param_type(__mean, __stddev)), __v_hot_(false) {}
#endif
_LIBCPP_INLINE_VISIBILITY
explicit normal_distribution(const param_type& __p)
- : __p_(__p), _V_hot_(false) {}
+ : __p_(__p), __v_hot_(false) {}
_LIBCPP_INLINE_VISIBILITY
- void reset() {_V_hot_ = false;}
+ void reset() {__v_hot_ = false;}
// generating functions
template<class _URNG>
@@ -107,8 +107,8 @@ public:
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_);}
+ {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)
@@ -134,10 +134,10 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
{
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
result_type _Up;
- if (_V_hot_)
+ if (__v_hot_)
{
- _V_hot_ = false;
- _Up = _V_;
+ __v_hot_ = false;
+ _Up = __v_;
}
else
{
@@ -152,15 +152,15 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
__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;
+ __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>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const normal_distribution<_RT>& __x)
{
@@ -170,14 +170,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
_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_;
+ __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>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
normal_distribution<_RT>& __x)
{
@@ -197,8 +197,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
if (!__is.fail())
{
__x.param(param_type(__mean, __stddev));
- __x._V_hot_ = _V_hot;
- __x._V_ = _Vp;
+ __x.__v_hot_ = _V_hot;
+ __x.__v_ = _Vp;
}
return __is;
}
diff --git a/libcxx/include/__random/piecewise_constant_distribution.h b/libcxx/include/__random/piecewise_constant_distribution.h
index 9c9e14b16d6e..a1f3ef9df50e 100644
--- a/libcxx/include/__random/piecewise_constant_distribution.h
+++ b/libcxx/include/__random/piecewise_constant_distribution.h
@@ -294,7 +294,7 @@ piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_t
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const piecewise_constant_distribution<_RT>& __x)
{
@@ -320,7 +320,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
piecewise_constant_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/piecewise_linear_distribution.h b/libcxx/include/__random/piecewise_linear_distribution.h
index 05f00cef06ef..fc2eb47c7b0f 100644
--- a/libcxx/include/__random/piecewise_linear_distribution.h
+++ b/libcxx/include/__random/piecewise_linear_distribution.h
@@ -310,7 +310,7 @@ piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_typ
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const piecewise_linear_distribution<_RT>& __x)
{
@@ -336,7 +336,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
piecewise_linear_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/poisson_distribution.h b/libcxx/include/__random/poisson_distribution.h
index ef55b1be4844..334c6102b341 100644
--- a/libcxx/include/__random/poisson_distribution.h
+++ b/libcxx/include/__random/poisson_distribution.h
@@ -245,7 +245,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
}
template <class _CharT, class _Traits, class _IntType>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const poisson_distribution<_IntType>& __x)
{
@@ -257,7 +257,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IntType>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
poisson_distribution<_IntType>& __x)
{
diff --git a/libcxx/include/__random/shuffle_order_engine.h b/libcxx/include/__random/shuffle_order_engine.h
index c2f76f609ae5..4a27289c2f81 100644
--- a/libcxx/include/__random/shuffle_order_engine.h
+++ b/libcxx/include/__random/shuffle_order_engine.h
@@ -60,8 +60,8 @@ public:
private:
_Engine __e_;
- result_type _V_[__k];
- result_type _Y_;
+ result_type __v_[__k];
+ result_type __y_;
public:
// engine characteristics
@@ -157,8 +157,8 @@ private:
void __init()
{
for (size_t __i = 0; __i < __k; ++__i)
- _V_[__i] = __e_();
- _Y_ = __e_();
+ __v_[__i] = __e_();
+ __y_ = __e_();
}
_LIBCPP_INLINE_VISIBILITY
@@ -190,11 +190,11 @@ private:
>::type
__eval(__uratio<_Np, _Dp>)
{
- const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min)
+ 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_;
+ __y_ = __v_[__j];
+ __v_[__j] = __e_();
+ return __y_;
}
template <uint64_t __n, uint64_t __d>
@@ -204,10 +204,10 @@ private:
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_;
+ const size_t __j = static_cast<size_t>(_Fp * (__y_ - _Min));
+ __y_ = __v_[__j];
+ __v_[__j] = __e_();
+ return __y_;
}
};
@@ -215,12 +215,12 @@ 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
+_LIBCPP_HIDE_FROM_ABI 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_) &&
+ return __x.__y_ == __y.__y_ && _VSTD::equal(__x.__v_, __x.__v_ + _Kp, __y.__v_) &&
__x.__e_ == __y.__e_;
}
@@ -236,7 +236,7 @@ operator!=(
template <class _CharT, class _Traits,
class _Eng, size_t _Kp>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const shuffle_order_engine<_Eng, _Kp>& __x)
{
@@ -245,15 +245,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
__os.flags(_Ostream::dec | _Ostream::left);
_CharT __sp = __os.widen(' ');
__os.fill(__sp);
- __os << __x.__e_ << __sp << __x._V_[0];
+ __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_;
+ __os << __sp << __x.__v_[__i];
+ return __os << __sp << __x.__y_;
}
template <class _CharT, class _Traits,
class _Eng, size_t _Kp>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
shuffle_order_engine<_Eng, _Kp>& __x)
{
@@ -270,8 +270,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
{
__x.__e_ = __e;
for (size_t __i = 0; __i < _Kp; ++__i)
- __x._V_[__i] = _Vp[__i];
- __x._Y_ = _Vp[_Kp];
+ __x.__v_[__i] = _Vp[__i];
+ __x.__y_ = _Vp[_Kp];
}
return __is;
}
diff --git a/libcxx/include/__random/student_t_distribution.h b/libcxx/include/__random/student_t_distribution.h
index 9e95f97cefab..64847aa66ae7 100644
--- a/libcxx/include/__random/student_t_distribution.h
+++ b/libcxx/include/__random/student_t_distribution.h
@@ -118,7 +118,7 @@ student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const student_t_distribution<_RT>& __x)
{
@@ -131,7 +131,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
student_t_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h
index fdbe2d2e9be3..b25ca84e3afd 100644
--- a/libcxx/include/__random/subtract_with_carry_engine.h
+++ b/libcxx/include/__random/subtract_with_carry_engine.h
@@ -33,7 +33,7 @@ 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
+_LIBCPP_HIDE_FROM_ABI bool
operator==(
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
@@ -47,13 +47,13 @@ operator!=(
template <class _CharT, class _Traits,
class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
@@ -251,7 +251,7 @@ subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()
}
template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)
@@ -305,7 +305,7 @@ operator!=(
template <class _CharT, class _Traits,
class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
{
@@ -325,7 +325,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
template <class _CharT, class _Traits,
class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
{
diff --git a/libcxx/include/__random/uniform_int_distribution.h b/libcxx/include/__random/uniform_int_distribution.h
index 46b627f45da9..b7db8a3f9cbb 100644
--- a/libcxx/include/__random/uniform_int_distribution.h
+++ b/libcxx/include/__random/uniform_int_distribution.h
@@ -9,7 +9,6 @@
#ifndef _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
#define _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
-#include <__bits>
#include <__config>
#include <__random/is_valid.h>
#include <__random/log2.h>
@@ -38,12 +37,8 @@ public:
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;
+ typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
+ _Working_result_type;
_Engine& __e_;
size_t __w_;
@@ -178,8 +173,10 @@ public:
result_type a() const {return __a_;}
result_type b() const {return __b_;}
+ _LIBCPP_HIDE_FROM_ABI
friend bool operator==(const param_type& __x, const param_type& __y)
{return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ _LIBCPP_HIDE_FROM_ABI
friend bool operator!=(const param_type& __x, const param_type& __y)
{return !(__x == __y);}
};
@@ -218,9 +215,11 @@ public:
result_type min() const {return a();}
result_type max() const {return b();}
+ _LIBCPP_HIDE_FROM_ABI
friend bool operator==(const uniform_int_distribution& __x,
const uniform_int_distribution& __y)
{return __x.__p_ == __y.__p_;}
+ _LIBCPP_HIDE_FROM_ABI
friend bool operator!=(const uniform_int_distribution& __x,
const uniform_int_distribution& __y)
{return !(__x == __y);}
@@ -233,8 +232,8 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
- typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,
- typename make_unsigned<result_type>::type>::type _UIntType;
+ typedef __conditional_t<sizeof(result_type) <= sizeof(uint32_t), uint32_t, __make_unsigned_t<result_type> >
+ _UIntType;
const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
if (_Rp == 1)
return __p.a();
@@ -242,7 +241,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
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;
+ size_t __w = _Dt - std::__countl_zero(_Rp) - 1;
if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
++__w;
_Eng __e(__g, __w);
@@ -255,7 +254,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
}
template <class _CharT, class _Traits, class _IT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const uniform_int_distribution<_IT>& __x)
{
@@ -268,7 +267,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _IT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
uniform_int_distribution<_IT>& __x)
{
diff --git a/libcxx/include/__random/uniform_real_distribution.h b/libcxx/include/__random/uniform_real_distribution.h
index 7d2ecda732fe..b52b68977f82 100644
--- a/libcxx/include/__random/uniform_real_distribution.h
+++ b/libcxx/include/__random/uniform_real_distribution.h
@@ -123,7 +123,7 @@ uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& _
}
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const uniform_real_distribution<_RT>& __x)
{
@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
uniform_real_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__random/weibull_distribution.h b/libcxx/include/__random/weibull_distribution.h
index 85bae65096cb..df834e6557c8 100644
--- a/libcxx/include/__random/weibull_distribution.h
+++ b/libcxx/include/__random/weibull_distribution.h
@@ -115,7 +115,7 @@ public:
};
template <class _CharT, class _Traits, class _RT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const weibull_distribution<_RT>& __x)
{
@@ -130,7 +130,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template <class _CharT, class _Traits, class _RT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
weibull_distribution<_RT>& __x)
{
diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h
index 0f1cca033a23..e48a71adf7e8 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_ACCESS_H
#define _LIBCPP___RANGES_ACCESS_H
@@ -14,8 +15,13 @@
#include <__iterator/concepts.h>
#include <__iterator/readable_traits.h>
#include <__ranges/enable_borrowed_range.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
#include <__utility/auto_cast.h>
-#include <type_traits>
+#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -99,7 +105,7 @@ inline namespace __cpo {
namespace ranges {
template <class _Tp>
- using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
+ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
} // namespace ranges
// [range.access.end]
diff --git a/libcxx/include/__ranges/all.h b/libcxx/include/__ranges/all.h
index 181477419c85..511f7b3b46f3 100644
--- a/libcxx/include/__ranges/all.h
+++ b/libcxx/include/__ranges/all.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_ALL_H
#define _LIBCPP___RANGES_ALL_H
@@ -28,7 +29,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges::views {
@@ -72,11 +73,11 @@ inline namespace __cpo {
} // namespace __cpo
template<ranges::viewable_range _Range>
-using all_t = decltype(views::all(declval<_Range>()));
+using all_t = decltype(views::all(std::declval<_Range>()));
} // namespace ranges::views
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/as_rvalue_view.h b/libcxx/include/__ranges/as_rvalue_view.h
new file mode 100644
index 000000000000..422d8a8e0834
--- /dev/null
+++ b/libcxx/include/__ranges/as_rvalue_view.h
@@ -0,0 +1,137 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_AS_RVALUE_H
+#define _LIBCPP___RANGES_AS_RVALUE_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__iterator/move_iterator.h>
+#include <__iterator/move_sentinel.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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+template <view _View>
+ requires input_range<_View>
+class as_rvalue_view : public view_interface<as_rvalue_view<_View>> {
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+
+public:
+ _LIBCPP_HIDE_FROM_ABI as_rvalue_view()
+ requires default_initializable<_View>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit as_rvalue_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()
+ requires(!__simple_view<_View>)
+ {
+ return move_iterator(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+ requires range<const _View>
+ {
+ return move_iterator(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+ requires(!__simple_view<_View>)
+ {
+ if constexpr (common_range<_View>) {
+ return move_iterator(ranges::end(__base_));
+ } else {
+ return move_sentinel(ranges::end(__base_));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+ requires range<const _View>
+ {
+ if constexpr (common_range<const _View>) {
+ return move_iterator(ranges::end(__base_));
+ } else {
+ return move_sentinel(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>
+as_rvalue_view(_Range&&) -> as_rvalue_view<views::all_t<_Range>>;
+
+template <class _View>
+inline constexpr bool enable_borrowed_range<as_rvalue_view<_View>> = enable_borrowed_range<_View>;
+
+namespace views {
+namespace __as_rvalue {
+struct __fn : __range_adaptor_closure<__fn> {
+ template <class _Range>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
+ noexcept(noexcept(/**/ as_rvalue_view(std::forward<_Range>(__range))))
+ -> decltype(/*--*/ as_rvalue_view(std::forward<_Range>(__range))) {
+ return /*-------------*/ as_rvalue_view(std::forward<_Range>(__range));
+ }
+
+ template <class _Range>
+ requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
+ _LIBCPP_NODISCARD_EXT _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));
+ }
+};
+} // namespace __as_rvalue
+
+inline namespace __cpo {
+constexpr auto as_rvalue = __as_rvalue::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___RANGES_AS_RVALUE_H
diff --git a/libcxx/include/__ranges/common_view.h b/libcxx/include/__ranges/common_view.h
index 61b9b61f26aa..8d7ae5841579 100644
--- a/libcxx/include/__ranges/common_view.h
+++ b/libcxx/include/__ranges/common_view.h
@@ -6,9 +6,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_COMMON_VIEW_H
#define _LIBCPP___RANGES_COMMON_VIEW_H
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
#include <__config>
#include <__iterator/common_iterator.h>
#include <__iterator/iterator_traits.h>
@@ -21,7 +24,6 @@
#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)
@@ -30,7 +32,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -128,7 +130,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h
index 87df1d18baf8..e34c545578ab 100644
--- a/libcxx/include/__ranges/concepts.h
+++ b/libcxx/include/__ranges/concepts.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_CONCEPTS_H
#define _LIBCPP___RANGES_CONCEPTS_H
@@ -23,8 +24,12 @@
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/enable_view.h>
#include <__ranges/size.h>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
#include <initializer_list>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -54,7 +59,7 @@ namespace ranges {
// `iterator_t` defined in <__ranges/access.h>
template <range _Rp>
- using sentinel_t = decltype(ranges::end(declval<_Rp&>()));
+ using sentinel_t = decltype(ranges::end(std::declval<_Rp&>()));
template <range _Rp>
using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
@@ -73,7 +78,7 @@ namespace ranges {
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
template<sized_range _Rp>
- using range_size_t = decltype(ranges::size(declval<_Rp&>()));
+ using range_size_t = decltype(ranges::size(std::declval<_Rp&>()));
// `disable_sized_range` defined in `<__ranges/size.h>`
diff --git a/libcxx/include/__ranges/copyable_box.h b/libcxx/include/__ranges/copyable_box.h
index 6012497db5e8..fb3d6e409c8f 100644
--- a/libcxx/include/__ranges/copyable_box.h
+++ b/libcxx/include/__ranges/copyable_box.h
@@ -10,11 +10,13 @@
#ifndef _LIBCPP___RANGES_COPYABLE_BOX_H
#define _LIBCPP___RANGES_COPYABLE_BOX_H
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/movable.h>
#include <__config>
#include <__memory/addressof.h>
#include <__memory/construct_at.h>
#include <__utility/move.h>
-#include <concepts>
#include <optional>
#include <type_traits>
@@ -24,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// __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
@@ -171,7 +173,7 @@ namespace ranges {
};
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/counted.h b/libcxx/include/__ranges/counted.h
index f45f1e890085..138aa0e1dde5 100644
--- a/libcxx/include/__ranges/counted.h
+++ b/libcxx/include/__ranges/counted.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_COUNTED_H
#define _LIBCPP___RANGES_COUNTED_H
@@ -29,7 +30,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges::views {
@@ -74,7 +75,7 @@ inline namespace __cpo {
} // namespace ranges::views
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/dangling.h b/libcxx/include/__ranges/dangling.h
index 525b5ff0aabe..c10453454dc3 100644
--- a/libcxx/include/__ranges/dangling.h
+++ b/libcxx/include/__ranges/dangling.h
@@ -13,7 +13,7 @@
#include <__config>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
-#include <type_traits>
+#include <__type_traits/conditional.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index 35d1af1e648f..0ac25b52c727 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_DATA_H
#define _LIBCPP___RANGES_DATA_H
@@ -15,8 +16,13 @@
#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
#include <__ranges/access.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_pointer.h>
+#include <__type_traits/remove_reference.h>
#include <__utility/auto_cast.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__ranges/drop_view.h b/libcxx/include/__ranges/drop_view.h
index b2a8ee581475..8f3564a8c760 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -6,11 +6,14 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_DROP_VIEW_H
#define _LIBCPP___RANGES_DROP_VIEW_H
#include <__algorithm/min.h>
#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
#include <__config>
#include <__functional/bind_back.h>
#include <__fwd/span.h>
@@ -33,7 +36,6 @@
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -45,7 +47,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<view _View>
@@ -297,7 +299,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/drop_while_view.h b/libcxx/include/__ranges/drop_while_view.h
new file mode 100644
index 000000000000..7c28992f1874
--- /dev/null
+++ b/libcxx/include/__ranges/drop_while_view.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___RANGES_DROP_WHILE_VIEW_H
+#define _LIBCPP___RANGES_DROP_WHILE_VIEW_H
+
+#include <__algorithm/ranges_find_if_not.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_object.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.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 >= 20
+
+namespace ranges {
+
+template <view _View, class _Pred>
+ requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
+class drop_while_view : public view_interface<drop_while_view<_View, _Pred>> {
+public:
+ _LIBCPP_HIDE_FROM_ABI drop_while_view()
+ requires default_initializable<_View> && default_initializable<_Pred>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr drop_while_view(_View __base, _Pred __pred)
+ : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
+
+ _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 const _Pred& pred() const { return *__pred_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
+ _LIBCPP_ASSERT(__pred_.__has_value(),
+ "drop_while_view needs to have a non-empty predicate before calling begin() -- did a previous "
+ "assignment to this drop_while_view fail?");
+ if constexpr (_UseCache) {
+ if (!__cached_begin_.__has_value()) {
+ __cached_begin_.__emplace(ranges::find_if_not(__base_, std::cref(*__pred_)));
+ }
+ return *__cached_begin_;
+ } else {
+ return ranges::find_if_not(__base_, std::cref(*__pred_));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() { return ranges::end(__base_); }
+
+private:
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
+
+ static constexpr bool _UseCache = forward_range<_View>;
+ using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
+};
+
+template <class _View, class _Pred>
+inline constexpr bool enable_borrowed_range<drop_while_view<_View, _Pred>> = enable_borrowed_range<_View>;
+
+template <class _Range, class _Pred>
+drop_while_view(_Range&&, _Pred) -> drop_while_view<views::all_t<_Range>, _Pred>;
+
+namespace views {
+namespace __drop_while {
+
+struct __fn {
+ template <class _Range, class _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
+ noexcept(noexcept(/**/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
+ -> decltype(/*--*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
+ return /*-------------*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
+ }
+
+ template <class _Pred>
+ requires constructible_from<decay_t<_Pred>, _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
+ return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
+ }
+};
+
+} // namespace __drop_while
+
+inline namespace __cpo {
+inline constexpr auto drop_while = __drop_while::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_DROP_WHILE_VIEW_H
diff --git a/libcxx/include/__ranges/elements_view.h b/libcxx/include/__ranges/elements_view.h
new file mode 100644
index 000000000000..3afd6ddbe8f2
--- /dev/null
+++ b/libcxx/include/__ranges/elements_view.h
@@ -0,0 +1,423 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_ELEMENTS_VIEW_H
+#define _LIBCPP___RANGES_ELEMENTS_VIEW_H
+
+#include <__compare/three_way_comparable.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__config>
+#include <__fwd/get.h>
+#include <__iterator/concepts.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 <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_like.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/maybe_const.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
+#include <__utility/forward.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 _LIBCPP_STD_VER >= 20
+
+namespace ranges {
+
+template <class _View, size_t _Np, bool _Const>
+class __elements_view_iterator;
+
+template <class _View, size_t _Np, bool _Const>
+class __elements_view_sentinel;
+
+template <class _Tp, size_t _Np>
+concept __has_tuple_element = __tuple_like<_Tp> && _Np < tuple_size<_Tp>::value;
+
+template <class _Tp, size_t _Np>
+concept __returnable_element = is_reference_v<_Tp> || move_constructible<tuple_element_t<_Np, _Tp>>;
+
+template <input_range _View, size_t _Np>
+ requires view<_View> && __has_tuple_element<range_value_t<_View>, _Np> &&
+ __has_tuple_element<remove_reference_t<range_reference_t<_View>>, _Np> &&
+ __returnable_element<range_reference_t<_View>, _Np>
+class elements_view : public view_interface<elements_view<_View, _Np>> {
+public:
+ _LIBCPP_HIDE_FROM_ABI elements_view()
+ requires default_initializable<_View>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit elements_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()
+ requires(!__simple_view<_View>)
+ {
+ return __iterator</*_Const=*/false>(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+ requires range<const _View>
+ {
+ return __iterator</*_Const=*/true>(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+ requires(!__simple_view<_View> && !common_range<_View>)
+ {
+ return __sentinel</*_Const=*/false>{ranges::end(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+ requires(!__simple_view<_View> && common_range<_View>)
+ {
+ return __iterator</*_Const=*/false>{ranges::end(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+ requires range<const _View>
+ {
+ return __sentinel</*_Const=*/true>{ranges::end(__base_)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+ requires common_range<const _View>
+ {
+ return __iterator</*_Const=*/true>{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_);
+ }
+
+private:
+ template <bool _Const>
+ using __iterator = __elements_view_iterator<_View, _Np, _Const>;
+
+ template <bool _Const>
+ using __sentinel = __elements_view_sentinel<_View, _Np, _Const>;
+
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+};
+
+template <class, size_t>
+struct __elements_view_iterator_category_base {};
+
+template <forward_range _Base, size_t _Np>
+struct __elements_view_iterator_category_base<_Base, _Np> {
+ static consteval auto __get_iterator_category() {
+ using _Result = decltype(std::get<_Np>(*std::declval<iterator_t<_Base>>()));
+ using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category;
+
+ if constexpr (!is_lvalue_reference_v<_Result>) {
+ return input_iterator_tag{};
+ } else if constexpr (derived_from<_Cat, random_access_iterator_tag>) {
+ return random_access_iterator_tag{};
+ } else {
+ return _Cat{};
+ }
+ }
+
+ using iterator_category = decltype(__get_iterator_category());
+};
+
+template <class _View, size_t _Np, bool _Const>
+class __elements_view_iterator : public __elements_view_iterator_category_base<__maybe_const<_Const, _View>, _Np> {
+ template <class, size_t, bool >
+ friend class __elements_view_iterator;
+
+ template <class, size_t, bool >
+ friend class __elements_view_sentinel;
+
+ using _Base = __maybe_const<_Const, _View>;
+
+ iterator_t<_Base> __current_ = iterator_t<_Base>();
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_element(const iterator_t<_Base>& __i) {
+ if constexpr (is_reference_v<range_reference_t<_Base>>) {
+ return std::get<_Np>(*__i);
+ } else {
+ using _Element = remove_cv_t<tuple_element_t<_Np, range_reference_t<_Base>>>;
+ return static_cast<_Element>(std::get<_Np>(*__i));
+ }
+ }
+
+ static consteval auto __get_iterator_concept() {
+ if constexpr (random_access_range<_Base>) {
+ return random_access_iterator_tag{};
+ } else if constexpr (bidirectional_range<_Base>) {
+ return bidirectional_iterator_tag{};
+ } else if constexpr (forward_range<_Base>) {
+ return forward_iterator_tag{};
+ } else {
+ return input_iterator_tag{};
+ }
+ }
+
+public:
+ using iterator_concept = decltype(__get_iterator_concept());
+ using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>;
+ using difference_type = range_difference_t<_Base>;
+
+ _LIBCPP_HIDE_FROM_ABI __elements_view_iterator()
+ requires default_initializable<iterator_t<_Base>>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __elements_view_iterator(iterator_t<_Base> __current)
+ : __current_(std::move(__current)) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator(__elements_view_iterator<_View, _Np, !_Const> __i)
+ requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
+ : __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 { return __get_element(__current_); }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator++() {
+ ++__current_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++__current_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator operator++(int)
+ requires forward_range<_Base>
+ {
+ auto temp = *this;
+ ++__current_;
+ return temp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator--()
+ requires bidirectional_range<_Base>
+ {
+ --__current_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator operator--(int)
+ requires bidirectional_range<_Base>
+ {
+ auto temp = *this;
+ --__current_;
+ return temp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator+=(difference_type __n)
+ requires random_access_range<_Base>
+ {
+ __current_ += __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_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
+ requires random_access_range<_Base>
+ {
+ return __get_element(__current_ + __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires equality_comparable<iterator_t<_Base>>
+ {
+ return __x.__current_ == __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator<(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ < __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator>(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __y < __x;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator<=(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return !(__y < __x);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator>=(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return !(__x < __y);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr auto
+ operator<=>(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
+ {
+ return __x.__current_ <=> __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
+ operator+(const __elements_view_iterator& __x, difference_type __y)
+ requires random_access_range<_Base>
+ {
+ return __elements_view_iterator{__x} += __y;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
+ operator+(difference_type __x, const __elements_view_iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __y + __x;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
+ operator-(const __elements_view_iterator& __x, difference_type __y)
+ requires random_access_range<_Base>
+ {
+ return __elements_view_iterator{__x} -= __y;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
+ operator-(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
+ requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
+ {
+ return __x.__current_ - __y.__current_;
+ }
+};
+
+template <class _View, size_t _Np, bool _Const>
+class __elements_view_sentinel {
+private:
+ using _Base = __maybe_const<_Const, _View>;
+ _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+
+ template <class, size_t, bool >
+ friend class __elements_view_sentinel;
+
+ template <bool _AnyConst>
+ _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
+ __get_current(const __elements_view_iterator<_View, _Np, _AnyConst>& __iter) {
+ return (__iter.__current_);
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI __elements_view_sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __elements_view_sentinel(sentinel_t<_Base> __end)
+ : __end_(std::move(__end)) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_sentinel(__elements_view_sentinel<_View, _Np, !_Const> __other)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(std::move(__other.__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 __elements_view_iterator<_View, _Np, _OtherConst>& __x, const __elements_view_sentinel& __y) {
+ return __get_current(__x) == __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 __elements_view_iterator<_View, _Np, _OtherConst>& __x, const __elements_view_sentinel& __y) {
+ return __get_current(__x) - __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 __elements_view_sentinel& __x, const __elements_view_iterator<_View, _Np, _OtherConst>& __y) {
+ return __x.__end_ - __get_current(__y);
+ }
+};
+
+template <class _Tp, size_t _Np>
+inline constexpr bool enable_borrowed_range<elements_view<_Tp, _Np>> = enable_borrowed_range<_Tp>;
+
+template <class _Tp>
+using keys_view = elements_view<_Tp, 0>;
+template <class _Tp>
+using values_view = elements_view<_Tp, 1>;
+
+namespace views {
+namespace __elements {
+
+template <size_t _Np>
+struct __fn : __range_adaptor_closure<__fn<_Np>> {
+ template <class _Range>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
+ /**/ noexcept(noexcept(elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range))))
+ /*------*/ -> decltype(elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range))) {
+ /*-------------*/ return elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range));
+ }
+};
+} // namespace __elements
+
+inline namespace __cpo {
+template <size_t _Np>
+inline constexpr auto elements = __elements::__fn<_Np>{};
+inline constexpr auto keys = elements<0>;
+inline constexpr auto values = elements<1>;
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_ELEMENTS_VIEW_H
diff --git a/libcxx/include/__ranges/empty.h b/libcxx/include/__ranges/empty.h
index 46c97ca7e329..8a1c75c0bae0 100644
--- a/libcxx/include/__ranges/empty.h
+++ b/libcxx/include/__ranges/empty.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_EMPTY_H
#define _LIBCPP___RANGES_EMPTY_H
@@ -14,7 +15,6 @@
#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
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.prim.empty]
@@ -75,7 +75,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/empty_view.h b/libcxx/include/__ranges/empty_view.h
index 3299fe825ddf..58e69ac19f29 100644
--- a/libcxx/include/__ranges/empty_view.h
+++ b/libcxx/include/__ranges/empty_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
#define _LIBCPP___RANGES_EMPTY_VIEW_H
@@ -20,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<class _Tp>
@@ -45,7 +46,7 @@ namespace ranges {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/enable_view.h b/libcxx/include/__ranges/enable_view.h
index a1e5721404cd..c85064b915ab 100644
--- a/libcxx/include/__ranges/enable_view.h
+++ b/libcxx/include/__ranges/enable_view.h
@@ -10,9 +10,12 @@
#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
#define _LIBCPP___RANGES_ENABLE_VIEW_H
+#include <__concepts/derived_from.h>
+#include <__concepts/same_as.h>
#include <__config>
-#include <concepts>
-#include <type_traits>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__ranges/filter_view.h b/libcxx/include/__ranges/filter_view.h
index b040ea57b779..f8633a3fee84 100644
--- a/libcxx/include/__ranges/filter_view.h
+++ b/libcxx/include/__ranges/filter_view.h
@@ -6,10 +6,15 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_FILTER_VIEW_H
#define _LIBCPP___RANGES_FILTER_VIEW_H
#include <__algorithm/ranges_find_if.h>
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
#include <__config>
#include <__debug>
#include <__functional/bind_back.h>
@@ -30,7 +35,6 @@
#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)
@@ -39,9 +43,18 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
+
+ template <input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
+ requires view<_View> && is_object_v<_Pred>
+ class __filter_view_iterator;
+
+ template <input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
+ requires view<_View> && is_object_v<_Pred>
+ class __filter_view_sentinel;
+
template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
requires view<_View> && is_object_v<_Pred>
class filter_view : public view_interface<filter_view<_View, _Pred>> {
@@ -54,8 +67,11 @@ namespace ranges {
using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
_LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
- class __iterator;
- class __sentinel;
+ using __iterator = __filter_view_iterator<_View, _Pred>;
+ using __sentinel = __filter_view_sentinel<_View, _Pred>;
+
+ friend __iterator;
+ friend __sentinel;
public:
_LIBCPP_HIDE_FROM_ABI
@@ -115,10 +131,13 @@ namespace ranges {
template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
requires view<_View> && is_object_v<_Pred>
- class filter_view<_View, _Pred>::__iterator : public __filter_iterator_category<_View> {
+ class __filter_view_iterator : public __filter_iterator_category<_View> {
+
+ using __filter_view = filter_view<_View, _Pred>;
+
public:
_LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();
- _LIBCPP_NO_UNIQUE_ADDRESS filter_view* __parent_ = nullptr;
+ _LIBCPP_NO_UNIQUE_ADDRESS __filter_view* __parent_ = nullptr;
using iterator_concept =
_If<bidirectional_range<_View>, bidirectional_iterator_tag,
@@ -130,10 +149,10 @@ namespace ranges {
using difference_type = range_difference_t<_View>;
_LIBCPP_HIDE_FROM_ABI
- __iterator() requires default_initializable<iterator_t<_View>> = default;
+ __filter_view_iterator() requires default_initializable<iterator_t<_View>> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator(filter_view& __parent, iterator_t<_View> __current)
+ constexpr __filter_view_iterator(__filter_view& __parent, iterator_t<_View> __current)
: __current_(std::move(__current)), __parent_(std::addressof(__parent))
{ }
@@ -152,7 +171,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator++() {
+ constexpr __filter_view_iterator& operator++() {
__current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),
std::ref(*__parent_->__pred_));
return *this;
@@ -160,42 +179,42 @@ namespace ranges {
_LIBCPP_HIDE_FROM_ABI
constexpr void operator++(int) { ++*this; }
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator++(int) requires forward_range<_View> {
+ constexpr __filter_view_iterator operator++(int) requires forward_range<_View> {
auto __tmp = *this;
++*this;
return __tmp;
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator--() requires bidirectional_range<_View> {
+ constexpr __filter_view_iterator& operator--() requires bidirectional_range<_View> {
do {
--__current_;
} while (!std::invoke(*__parent_->__pred_, *__current_));
return *this;
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator--(int) requires bidirectional_range<_View> {
+ constexpr __filter_view_iterator operator--(int) requires bidirectional_range<_View> {
auto tmp = *this;
--*this;
return tmp;
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(__iterator const& __x, __iterator const& __y)
+ friend constexpr bool operator==(__filter_view_iterator const& __x, __filter_view_iterator const& __y)
requires equality_comparable<iterator_t<_View>>
{
return __x.__current_ == __y.__current_;
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr range_rvalue_reference_t<_View> iter_move(__iterator const& __it)
+ friend constexpr range_rvalue_reference_t<_View> iter_move(__filter_view_iterator const& __it)
noexcept(noexcept(ranges::iter_move(__it.__current_)))
{
return ranges::iter_move(__it.__current_);
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr void iter_swap(__iterator const& __x, __iterator const& __y)
+ friend constexpr void iter_swap(__filter_view_iterator const& __x, __filter_view_iterator const& __y)
noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
requires indirectly_swappable<iterator_t<_View>>
{
@@ -205,23 +224,25 @@ namespace ranges {
template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
requires view<_View> && is_object_v<_Pred>
- class filter_view<_View, _Pred>::__sentinel {
+ class __filter_view_sentinel {
+ using __filter_view = filter_view<_View, _Pred>;
+
public:
sentinel_t<_View> __end_ = sentinel_t<_View>();
_LIBCPP_HIDE_FROM_ABI
- __sentinel() = default;
+ __filter_view_sentinel() = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit __sentinel(filter_view& __parent)
+ constexpr explicit __filter_view_sentinel(__filter_view& __parent)
: __end_(ranges::end(__parent.__base_))
{ }
_LIBCPP_HIDE_FROM_ABI
constexpr sentinel_t<_View> base() const { return __end_; }
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) {
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(__filter_view_iterator<_View, _Pred> const& __x, __filter_view_sentinel const& __y) {
return __x.__current_ == __y.__end_;
}
};
@@ -252,7 +273,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index e1f03bafa03a..3654096b7e17 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
#define _LIBCPP___RANGES_IOTA_VIEW_H
@@ -39,7 +40,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<class _Int>
@@ -82,6 +83,14 @@ namespace ranges {
{ __j - __j } -> convertible_to<_IotaDiffT<_Iter>>;
};
+ template <weakly_incrementable _Start>
+ requires copyable<_Start>
+ struct __iota_view_iterator;
+
+ template <weakly_incrementable _Start, semiregular _BoundSentinel>
+ requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
+ struct __iota_view_sentinel;
+
template<class>
struct __iota_iterator_category {};
@@ -93,210 +102,9 @@ namespace ranges {
template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
- 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:
- _BoundSentinel __bound_sentinel_ = _BoundSentinel();
-
- public:
- _LIBCPP_HIDE_FROM_ABI
- __sentinel() = default;
- constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
-
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
- return __x.__value_ == __y.__bound_sentinel_;
- }
-
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
- requires sized_sentinel_for<_BoundSentinel, _Start>
- {
- return __x.__value_ - __y.__bound_sentinel_;
- }
-
- _LIBCPP_HIDE_FROM_ABI
- friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
- requires sized_sentinel_for<_BoundSentinel, _Start>
- {
- return -(__y - __x);
- }
- };
+ using __iterator = __iota_view_iterator<_Start>;
+ using __sentinel = __iota_view_sentinel<_Start, _BoundSentinel>;
_Start __value_ = _Start();
_BoundSentinel __bound_sentinel_ = _BoundSentinel();
@@ -377,6 +185,224 @@ namespace ranges {
template <class _Start, class _BoundSentinel>
inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
+ template <weakly_incrementable _Start>
+ requires copyable<_Start>
+ struct __iota_view_iterator : public __iota_iterator_category<_Start> {
+
+ template <weakly_incrementable _StartT, semiregular _BoundSentinelT>
+ requires __weakly_equality_comparable_with<_StartT, _BoundSentinelT> && copyable<_StartT>
+ 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
+ __iota_view_iterator() requires default_initializable<_Start> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __iota_view_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 __iota_view_iterator& operator++() {
+ ++__value_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) { ++*this; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iota_view_iterator operator++(int) requires incrementable<_Start> {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iota_view_iterator& operator--() requires __decrementable<_Start> {
+ --__value_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iota_view_iterator operator--(int) requires __decrementable<_Start> {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iota_view_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 __iota_view_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 __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires equality_comparable<_Start>
+ {
+ return __x.__value_ == __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return __x.__value_ < __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return __y < __x;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return !(__y < __x);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires totally_ordered<_Start>
+ {
+ return !(__x < __y);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr auto operator<=>(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
+ requires totally_ordered<_Start> && three_way_comparable<_Start>
+ {
+ return __x.__value_ <=> __y.__value_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iota_view_iterator operator+(__iota_view_iterator __i, difference_type __n)
+ requires __advanceable<_Start>
+ {
+ __i += __n;
+ return __i;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iota_view_iterator operator+(difference_type __n, __iota_view_iterator __i)
+ requires __advanceable<_Start>
+ {
+ return __i + __n;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iota_view_iterator operator-(__iota_view_iterator __i, difference_type __n)
+ requires __advanceable<_Start>
+ {
+ __i -= __n;
+ return __i;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr difference_type operator-(const __iota_view_iterator& __x, const __iota_view_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_;
+ }
+ };
+
+ template <weakly_incrementable _Start, semiregular _BoundSentinel>
+ requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
+ struct __iota_view_sentinel {
+
+ template <weakly_incrementable _StartT, semiregular _BoundSentinelT>
+ requires __weakly_equality_comparable_with<_StartT, _BoundSentinelT> && copyable<_StartT>
+ friend class iota_view;
+
+ using __iterator = __iota_view_iterator<_Start>;
+
+ private:
+ _BoundSentinel __bound_sentinel_ = _BoundSentinel();
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI
+ __iota_view_sentinel() = default;
+ constexpr explicit __iota_view_sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __iota_view_sentinel& __y) {
+ return __x.__value_ == __y.__bound_sentinel_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __iota_view_sentinel& __y)
+ requires sized_sentinel_for<_BoundSentinel, _Start>
+ {
+ return __x.__value_ - __y.__bound_sentinel_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Start> operator-(const __iota_view_sentinel& __x, const __iterator& __y)
+ requires sized_sentinel_for<_BoundSentinel, _Start>
+ {
+ return -(__y - __x);
+ }
+ };
+
namespace views {
namespace __iota {
struct __fn {
@@ -401,7 +427,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/istream_view.h b/libcxx/include/__ranges/istream_view.h
new file mode 100644
index 000000000000..69a9df35a4d2
--- /dev/null
+++ b/libcxx/include/__ranges/istream_view.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_ISTREAM_VIEW_H
+#define _LIBCPP___RANGES_ISTREAM_VIEW_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/movable.h>
+#include <__config>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/forward.h>
+#include <cstddef>
+#include <iosfwd>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _Val, class _CharT, class _Traits>
+concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& __is, _Val& __t) { __is >> __t; };
+
+template <movable _Val, class _CharT, class _Traits>
+ requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
+class __basic_istream_view_iterator;
+
+template <movable _Val, class _CharT, class _Traits = char_traits<_CharT>>
+ requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
+class basic_istream_view : public view_interface<basic_istream_view<_Val, _CharT, _Traits>> {
+ using __iterator = __basic_istream_view_iterator<_Val, _CharT, _Traits>;
+
+ template <movable _ValueType, class _CharType, class _TraitsType>
+ requires default_initializable<_ValueType> && __stream_extractable<_ValueType, _CharType, _TraitsType>
+ friend class __basic_istream_view_iterator;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream)
+ : __stream_(std::addressof(__stream)) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
+ *__stream_ >> __value_;
+ return __iterator{*this};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
+
+private:
+ basic_istream<_CharT, _Traits>* __stream_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Val __value_ = _Val();
+};
+
+template <movable _Val, class _CharT, class _Traits>
+ requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
+class __basic_istream_view_iterator {
+public:
+ using iterator_concept = input_iterator_tag;
+ using difference_type = ptrdiff_t;
+ using value_type = _Val;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __basic_istream_view_iterator(
+ basic_istream_view<_Val, _CharT, _Traits>& __parent) noexcept
+ : __parent_(std::addressof(__parent)) {}
+
+ __basic_istream_view_iterator(const __basic_istream_view_iterator&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator(__basic_istream_view_iterator&&) = default;
+
+ __basic_istream_view_iterator& operator=(const __basic_istream_view_iterator&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator=(__basic_istream_view_iterator&&) = default;
+
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator++() {
+ *__parent_->__stream_ >> __parent_->__value_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void operator++(int) { ++*this; }
+
+ _LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; }
+
+ _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __basic_istream_view_iterator& __x, default_sentinel_t) {
+ return !*__x.__get_parent_stream();
+ }
+
+private:
+ basic_istream_view<_Val, _CharT, _Traits>* __parent_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr basic_istream<_CharT, _Traits>* __get_parent_stream() const {
+ return __parent_->__stream_;
+ }
+};
+
+template <class _Val>
+using istream_view = basic_istream_view<_Val, char>;
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _Val>
+using wistream_view = basic_istream_view<_Val, wchar_t>;
+# endif
+
+namespace views {
+namespace __istream {
+
+// clang-format off
+template <class _Tp>
+struct __fn {
+ template <class _Up, class _UnCVRef = remove_cvref_t<_Up>>
+ requires derived_from<_UnCVRef, basic_istream<typename _UnCVRef::char_type,
+ typename _UnCVRef::traits_type>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Up&& __u) const
+ noexcept(noexcept(basic_istream_view<_Tp, typename _UnCVRef::char_type,
+ typename _UnCVRef::traits_type>(std::forward<_Up>(__u))))
+ -> decltype( basic_istream_view<_Tp, typename _UnCVRef::char_type,
+ typename _UnCVRef::traits_type>(std::forward<_Up>(__u)))
+ { return basic_istream_view<_Tp, typename _UnCVRef::char_type,
+ typename _UnCVRef::traits_type>(std::forward<_Up>(__u));
+ }
+};
+// clang-format on
+
+} // namespace __istream
+
+inline namespace __cpo {
+template <class _Tp>
+inline constexpr auto istream = __istream::__fn<_Tp>{};
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP___RANGES_ISTREAM_VIEW_H
diff --git a/libcxx/include/__ranges/join_view.h b/libcxx/include/__ranges/join_view.h
index b6fcce95aeda..869540fc99c2 100644
--- a/libcxx/include/__ranges/join_view.h
+++ b/libcxx/include/__ranges/join_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_JOIN_VIEW_H
#define _LIBCPP___RANGES_JOIN_VIEW_H
@@ -19,12 +20,16 @@
#include <__iterator/iter_move.h>
#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/iterator_with_data.h>
+#include <__iterator/segmented_iterator.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
+#include <__ranges/empty.h>
#include <__ranges/non_propagating_cache.h>
#include <__ranges/range_adaptor.h>
#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
#include <__utility/forward.h>
#include <optional>
#include <type_traits>
@@ -35,7 +40,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<class>
@@ -61,6 +66,14 @@ namespace ranges {
>;
};
+ template <input_range _View, bool _Const>
+ requires view<_View> && input_range<range_reference_t<_View>>
+ struct __join_view_iterator;
+
+ template <input_range _View, bool _Const>
+ requires view<_View> && input_range<range_reference_t<_View>>
+ struct __join_view_sentinel;
+
template<input_range _View>
requires view<_View> && input_range<range_reference_t<_View>>
class join_view
@@ -68,8 +81,22 @@ namespace ranges {
private:
using _InnerRange = range_reference_t<_View>;
- template<bool> struct __iterator;
- template<bool> struct __sentinel;
+ template<bool _Const>
+ using __iterator = __join_view_iterator<_View, _Const>;
+
+ template<bool _Const>
+ using __sentinel = __join_view_sentinel<_View, _Const>;
+
+ template <input_range _View2, bool _Const2>
+ requires view<_View2> && input_range<range_reference_t<_View2>>
+ friend struct __join_view_iterator;
+
+ template <input_range _View2, bool _Const2>
+ requires view<_View2> && input_range<range_reference_t<_View2>>
+ friend struct __join_view_sentinel;
+
+ template <class>
+ friend struct std::__segmented_iterator_traits;
static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
@@ -137,49 +164,57 @@ namespace ranges {
}
};
- template<input_range _View>
+ template<input_range _View, bool _Const>
requires view<_View> && input_range<range_reference_t<_View>>
- template<bool _Const> struct join_view<_View>::__sentinel {
- template<bool> friend struct __sentinel;
+ struct __join_view_sentinel {
+ template<input_range _View2, bool>
+ requires view<_View2> && input_range<range_reference_t<_View2>>
+ friend struct __join_view_sentinel;
private:
- using _Parent = __maybe_const<_Const, join_view>;
+ using _Parent = __maybe_const<_Const, join_view<_View>>;
using _Base = __maybe_const<_Const, _View>;
sentinel_t<_Base> __end_ = sentinel_t<_Base>();
public:
_LIBCPP_HIDE_FROM_ABI
- __sentinel() = default;
+ __join_view_sentinel() = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit __sentinel(_Parent& __parent)
+ constexpr explicit __join_view_sentinel(_Parent& __parent)
: __end_(ranges::end(__parent.__base_)) {}
_LIBCPP_HIDE_FROM_ABI
- constexpr __sentinel(__sentinel<!_Const> __s)
+ constexpr __join_view_sentinel(__join_view_sentinel<_View, !_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) {
+ friend constexpr bool operator==(const __join_view_iterator<_View, _OtherConst>& __x, const __join_view_sentinel& __y) {
return __x.__outer_ == __y.__end_;
}
};
- template<input_range _View>
+ template<input_range _View, bool _Const>
requires view<_View> && input_range<range_reference_t<_View>>
- template<bool _Const> struct join_view<_View>::__iterator
+ struct __join_view_iterator
: public __join_view_iterator_category<__maybe_const<_Const, _View>> {
- template<bool> friend struct __iterator;
+ template<input_range _View2, bool>
+ requires view<_View2> && input_range<range_reference_t<_View2>>
+ friend struct __join_view_iterator;
+
+ template <class>
+ friend struct std::__segmented_iterator_traits;
private:
- using _Parent = __maybe_const<_Const, join_view>;
+ using _Parent = __maybe_const<_Const, join_view<_View>>;
using _Base = __maybe_const<_Const, _View>;
using _Outer = iterator_t<_Base>;
using _Inner = iterator_t<range_reference_t<_Base>>;
+ using _InnerRange = range_reference_t<_View>;
static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;
@@ -208,9 +243,12 @@ namespace ranges {
__inner_.reset();
}
+ _LIBCPP_HIDE_FROM_ABI constexpr __join_view_iterator(_Parent* __parent, _Outer __outer, _Inner __inner)
+ : __outer_(std::move(__outer)), __inner_(std::move(__inner)), __parent_(__parent) {}
+
public:
using iterator_concept = _If<
- __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
+ __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
common_range<range_reference_t<_Base>>,
bidirectional_iterator_tag,
_If<
@@ -226,17 +264,17 @@ namespace ranges {
range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>;
_LIBCPP_HIDE_FROM_ABI
- __iterator() requires default_initializable<_Outer> = default;
+ __join_view_iterator() requires default_initializable<_Outer> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator(_Parent& __parent, _Outer __outer)
+ constexpr __join_view_iterator(_Parent& __parent, _Outer __outer)
: __outer_(std::move(__outer))
, __parent_(std::addressof(__parent)) {
__satisfy();
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator(__iterator<!_Const> __i)
+ constexpr __join_view_iterator(__join_view_iterator<_View, !_Const> __i)
requires _Const &&
convertible_to<iterator_t<_View>, _Outer> &&
convertible_to<iterator_t<_InnerRange>, _Inner>
@@ -257,7 +295,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator++() {
+ constexpr __join_view_iterator& operator++() {
auto&& __inner = [&]() -> auto&& {
if constexpr (__ref_is_glvalue)
return *__outer_;
@@ -277,7 +315,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator++(int)
+ constexpr __join_view_iterator operator++(int)
requires __ref_is_glvalue &&
forward_range<_Base> &&
forward_range<range_reference_t<_Base>>
@@ -288,7 +326,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator--()
+ constexpr __join_view_iterator& operator--()
requires __ref_is_glvalue &&
bidirectional_range<_Base> &&
bidirectional_range<range_reference_t<_Base>> &&
@@ -307,7 +345,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator--(int)
+ constexpr __join_view_iterator operator--(int)
requires __ref_is_glvalue &&
bidirectional_range<_Base> &&
bidirectional_range<range_reference_t<_Base>> &&
@@ -319,7 +357,7 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ friend constexpr bool operator==(const __join_view_iterator& __x, const __join_view_iterator& __y)
requires __ref_is_glvalue &&
equality_comparable<iterator_t<_Base>> &&
equality_comparable<iterator_t<range_reference_t<_Base>>>
@@ -328,14 +366,14 @@ namespace ranges {
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr decltype(auto) iter_move(const __iterator& __i)
+ friend constexpr decltype(auto) iter_move(const __join_view_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)
+ friend constexpr void iter_swap(const __join_view_iterator& __x, const __join_view_iterator& __y)
noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_)))
requires indirectly_swappable<_Inner>
{
@@ -345,7 +383,7 @@ namespace ranges {
template<class _Range>
explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
-
+
namespace views {
namespace __join_view {
struct __fn : __range_adaptor_closure<__fn> {
@@ -363,7 +401,51 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _View, bool _Const>
+ requires(ranges::common_range<typename ranges::__join_view_iterator<_View, _Const>::_Parent> &&
+ __is_cpp17_random_access_iterator<typename ranges::__join_view_iterator<_View, _Const>::_Outer>::value &&
+ __is_cpp17_random_access_iterator<typename ranges::__join_view_iterator<_View, _Const>::_Inner>::value)
+struct __segmented_iterator_traits<ranges::__join_view_iterator<_View, _Const>> {
+ using _JoinViewIterator = ranges::__join_view_iterator<_View, _Const>;
+
+ using __segment_iterator =
+ _LIBCPP_NODEBUG __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;
+ using __local_iterator = typename _JoinViewIterator::_Inner;
+
+ // TODO: Would it make sense to enable the optimization for other iterator types?
+
+ static constexpr _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_JoinViewIterator __iter) {
+ if (ranges::empty(__iter.__parent_->__base_))
+ return {};
+ if (!__iter.__inner_.has_value())
+ return __segment_iterator(--__iter.__outer_, __iter.__parent_);
+ return __segment_iterator(__iter.__outer_, __iter.__parent_);
+ }
+
+ static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_JoinViewIterator __iter) {
+ if (ranges::empty(__iter.__parent_->__base_))
+ return {};
+ if (!__iter.__inner_.has_value())
+ return ranges::end(*--__iter.__outer_);
+ return *__iter.__inner_;
+ }
+
+ static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __begin(__segment_iterator __iter) {
+ return ranges::begin(*__iter.__get_iter());
+ }
+
+ static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __end(__segment_iterator __iter) {
+ return ranges::end(*__iter.__get_iter());
+ }
+
+ static constexpr _LIBCPP_HIDE_FROM_ABI _JoinViewIterator
+ __compose(__segment_iterator __seg_iter, __local_iterator __local_iter) {
+ return _JoinViewIterator(
+ std::move(__seg_iter).__get_data(), std::move(__seg_iter).__get_iter(), std::move(__local_iter));
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/lazy_split_view.h b/libcxx/include/__ranges/lazy_split_view.h
index e559a76ef7b7..3a95075884b9 100644
--- a/libcxx/include/__ranges/lazy_split_view.h
+++ b/libcxx/include/__ranges/lazy_split_view.h
@@ -10,7 +10,6 @@
#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
-#include <__algorithm/in_in_result.h>
#include <__algorithm/ranges_find.h>
#include <__algorithm/ranges_mismatch.h>
#include <__concepts/constructible.h>
@@ -35,6 +34,7 @@
#include <__ranges/single_view.h>
#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <type_traits>
@@ -45,7 +45,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -458,7 +458,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/non_propagating_cache.h b/libcxx/include/__ranges/non_propagating_cache.h
index 7255705256d7..d50c577fc30f 100644
--- a/libcxx/include/__ranges/non_propagating_cache.h
+++ b/libcxx/include/__ranges/non_propagating_cache.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
#define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
@@ -14,7 +15,6 @@
#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>
@@ -24,7 +24,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
// __non_propagating_cache is a helper type that allows storing an optional value in it,
@@ -107,7 +107,7 @@ namespace ranges {
struct __empty_cache { };
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/owning_view.h b/libcxx/include/__ranges/owning_view.h
index ac1ef08fecc2..e150f6d9f248 100644
--- a/libcxx/include/__ranges/owning_view.h
+++ b/libcxx/include/__ranges/owning_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_OWNING_VIEW_H
#define _LIBCPP___RANGES_OWNING_VIEW_H
@@ -28,7 +29,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<range _Rp>
@@ -68,13 +69,14 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp>
{ return ranges::data(__r_); }
};
+ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(owning_view);
template<class _Tp>
inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>;
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/range_adaptor.h b/libcxx/include/__ranges/range_adaptor.h
index b65233b56359..37e48179e378 100644
--- a/libcxx/include/__ranges/range_adaptor.h
+++ b/libcxx/include/__ranges/range_adaptor.h
@@ -10,13 +10,16 @@
#ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H
#define _LIBCPP___RANGES_RANGE_ADAPTOR_H
+#include <__concepts/constructible.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/invocable.h>
+#include <__concepts/same_as.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)
@@ -25,7 +28,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// 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
@@ -41,6 +44,7 @@ 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)) { }
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
template <class _Tp>
concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
@@ -66,7 +70,7 @@ struct __range_adaptor_closure {
{ return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
};
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/rbegin.h b/libcxx/include/__ranges/rbegin.h
index 9291359fdf3b..26b47321de93 100644
--- a/libcxx/include/__ranges/rbegin.h
+++ b/libcxx/include/__ranges/rbegin.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_RBEGIN_H
#define _LIBCPP___RANGES_RBEGIN_H
@@ -25,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [ranges.access.rbegin]
@@ -123,7 +124,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/ref_view.h b/libcxx/include/__ranges/ref_view.h
index e69c715fb9e4..1e5f7466f321 100644
--- a/libcxx/include/__ranges/ref_view.h
+++ b/libcxx/include/__ranges/ref_view.h
@@ -6,9 +6,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_REF_VIEW_H
#define _LIBCPP___RANGES_REF_VIEW_H
+#include <__concepts/convertible_to.h>
+#include <__concepts/different_from.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -22,7 +25,6 @@
#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)
@@ -31,7 +33,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<range _Range>
@@ -45,7 +47,7 @@ namespace ranges {
public:
template<class _Tp>
requires __different_from<_Tp, ref_view> &&
- convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
+ convertible_to<_Tp, _Range&> && requires { __fun(std::declval<_Tp>()); }
_LIBCPP_HIDE_FROM_ABI
constexpr ref_view(_Tp&& __t)
: __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
@@ -79,7 +81,7 @@ public:
inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/rend.h b/libcxx/include/__ranges/rend.h
index e507b2587277..d2987e9fa8c3 100644
--- a/libcxx/include/__ranges/rend.h
+++ b/libcxx/include/__ranges/rend.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_REND_H
#define _LIBCPP___RANGES_REND_H
@@ -26,7 +27,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
// [range.access.rend]
@@ -127,7 +128,7 @@ inline namespace __cpo {
} // namespace __cpo
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/reverse_view.h b/libcxx/include/__ranges/reverse_view.h
index b1df8fbc337b..d7b137805448 100644
--- a/libcxx/include/__ranges/reverse_view.h
+++ b/libcxx/include/__ranges/reverse_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_REVERSE_VIEW_H
#define _LIBCPP___RANGES_REVERSE_VIEW_H
@@ -33,7 +34,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<view _View>
@@ -183,7 +184,7 @@ namespace ranges {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/single_view.h b/libcxx/include/__ranges/single_view.h
index 98ebe5f3839f..5c4b91869c1c 100644
--- a/libcxx/include/__ranges/single_view.h
+++ b/libcxx/include/__ranges/single_view.h
@@ -6,9 +6,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_SINGLE_VIEW_H
#define _LIBCPP___RANGES_SINGLE_VIEW_H
+#include <__concepts/constructible.h>
#include <__config>
#include <__ranges/copyable_box.h>
#include <__ranges/range_adaptor.h>
@@ -16,7 +18,6 @@
#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)
@@ -25,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<copy_constructible _Tp>
@@ -94,7 +95,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h
index 32ca4b854bc3..0ac8d63063d4 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -6,17 +6,23 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_SIZE_H
#define _LIBCPP___RANGES_SIZE_H
+#include <__concepts/arithmetic.h>
#include <__concepts/class_or_enum.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/access.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/make_signed.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/auto_cast.h>
-#include <concepts>
-#include <type_traits>
+#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -65,7 +71,7 @@ concept __difference =
__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>()))>;
+ { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(std::declval<_Tp>()))>;
};
struct __fn {
diff --git a/libcxx/include/__ranges/split_view.h b/libcxx/include/__ranges/split_view.h
new file mode 100644
index 000000000000..9758ee935f29
--- /dev/null
+++ b/libcxx/include/__ranges/split_view.h
@@ -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___RANGES_SPLIT_VIEW_H
+#define _LIBCPP___RANGES_SPLIT_VIEW_H
+
+#include <__algorithm/ranges_search.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/empty.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/single_view.h>
+#include <__ranges/subrange.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.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 _LIBCPP_STD_VER >= 20
+
+namespace ranges {
+
+template <class _View, class _Pattern>
+struct __split_view_iterator;
+
+template <class _View, class _Pattern>
+struct __split_view_sentinel;
+
+template <forward_range _View, forward_range _Pattern>
+ requires view<_View> && view<_Pattern> &&
+ indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to>
+class split_view : public view_interface<split_view<_View, _Pattern>> {
+private:
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
+ using _Cache = __non_propagating_cache<subrange<iterator_t<_View>>>;
+ _Cache __cached_begin_ = _Cache();
+
+ template <class, class>
+ friend struct __split_view_iterator;
+
+ template <class, class>
+ friend struct __split_view_sentinel;
+
+ using __iterator = __split_view_iterator<_View, _Pattern>;
+ using __sentinel = __split_view_sentinel<_View, _Pattern>;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr subrange<iterator_t<_View>> __find_next(iterator_t<_View> __it) {
+ auto [__begin, __end] = ranges::search(subrange(__it, ranges::end(__base_)), __pattern_);
+ if (__begin != ranges::end(__base_) && ranges::empty(__pattern_)) {
+ ++__begin;
+ ++__end;
+ }
+ return {__begin, __end};
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI split_view()
+ requires default_initializable<_View> && default_initializable<_Pattern>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr split_view(_View __base, _Pattern __pattern)
+ : __base_(std::move(__base)), __pattern_(std::move((__pattern))) {}
+
+ template <forward_range _Range>
+ requires constructible_from<_View, views::all_t<_Range>> &&
+ constructible_from<_Pattern, single_view<range_value_t<_Range>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr split_view(_Range&& __range, range_value_t<_Range> __elem)
+ : __base_(views::all(std::forward<_Range>(__range))), __pattern_(views::single(std::move(__elem))) {}
+
+ _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 begin() {
+ if (!__cached_begin_.__has_value()) {
+ __cached_begin_.__emplace(__find_next(ranges::begin(__base_)));
+ }
+ return {*this, ranges::begin(__base_), *__cached_begin_};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
+ if constexpr (common_range<_View>) {
+ return __iterator{*this, ranges::end(__base_), {}};
+ } else {
+ return __sentinel{*this};
+ }
+ }
+};
+
+template <class _Range, class _Pattern>
+split_view(_Range&&, _Pattern&&) -> split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
+
+template <forward_range _Range>
+split_view(_Range&&, range_value_t<_Range>) -> split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
+
+template <class _View, class _Pattern>
+struct __split_view_iterator {
+private:
+ split_view<_View, _Pattern>* __parent_ = nullptr;
+ _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __cur_ = iterator_t<_View>();
+ _LIBCPP_NO_UNIQUE_ADDRESS subrange<iterator_t<_View>> __next_ = subrange<iterator_t<_View>>();
+ bool __trailing_empty_ = false;
+
+ template <class, class>
+ friend struct __split_view_sentinel;
+
+public:
+ using iterator_concept = forward_iterator_tag;
+ using iterator_category = input_iterator_tag;
+ using value_type = subrange<iterator_t<_View>>;
+ using difference_type = range_difference_t<_View>;
+
+ _LIBCPP_HIDE_FROM_ABI __split_view_iterator() = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator(
+ split_view<_View, _Pattern>& __parent, iterator_t<_View> __current, subrange<iterator_t<_View>> __next)
+ : __parent_(std::addressof(__parent)), __cur_(std::move(__current)), __next_(std::move(__next)) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() const { return __cur_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return {__cur_, __next_.begin()}; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator& operator++() {
+ __cur_ = __next_.begin();
+ if (__cur_ != ranges::end(__parent_->__base_)) {
+ __cur_ = __next_.end();
+ if (__cur_ == ranges::end(__parent_->__base_)) {
+ __trailing_empty_ = true;
+ __next_ = {__cur_, __cur_};
+ } else {
+ __next_ = __parent_->__find_next(__cur_);
+ }
+ } else {
+ __trailing_empty_ = false;
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator operator++(int) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(const __split_view_iterator& __x, const __split_view_iterator& __y) {
+ return __x.__cur_ == __y.__cur_ && __x.__trailing_empty_ == __y.__trailing_empty_;
+ }
+};
+
+template <class _View, class _Pattern>
+struct __split_view_sentinel {
+private:
+ _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_View> __end_ = sentinel_t<_View>();
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr bool
+ __equals(const __split_view_iterator<_View, _Pattern>& __x, const __split_view_sentinel& __y) {
+ return __x.__cur_ == __y.__end_ && !__x.__trailing_empty_;
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI __split_view_sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __split_view_sentinel(split_view<_View, _Pattern>& __parent)
+ : __end_(ranges::end(__parent.__base_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(const __split_view_iterator<_View, _Pattern>& __x, const __split_view_sentinel& __y) {
+ return __equals(__x, __y);
+ }
+};
+
+namespace views {
+namespace __split_view {
+struct __fn : __range_adaptor_closure<__fn> {
+ // clang-format off
+ template <class _Range, class _Pattern>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
+ noexcept(noexcept(split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
+ -> decltype( split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
+ { return split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); }
+ // clang-format on
+
+ template <class _Pattern>
+ requires constructible_from<decay_t<_Pattern>, _Pattern>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
+ return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
+ }
+};
+} // namespace __split_view
+
+inline namespace __cpo {
+inline constexpr auto split = __split_view::__fn{};
+} // namespace __cpo
+} // namespace views
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_SPLIT_VIEW_H
diff --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h
index 7e42da6ce7f9..2d9e4cc7e55e 100644
--- a/libcxx/include/__ranges/subrange.h
+++ b/libcxx/include/__ranges/subrange.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_SUBRANGE_H
#define _LIBCPP___RANGES_SUBRANGE_H
@@ -16,6 +17,8 @@
#include <__concepts/derived_from.h>
#include <__concepts/different_from.h>
#include <__config>
+#include <__fwd/get.h>
+#include <__fwd/subrange.h>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
@@ -26,9 +29,18 @@
#include <__ranges/enable_borrowed_range.h>
#include <__ranges/size.h>
#include <__ranges/view_interface.h>
-#include <__tuple>
+#include <__tuple_dir/pair_like.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_pointer.h>
#include <__utility/move.h>
-#include <type_traits>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,7 +48,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
template<class _From, class _To>
@@ -49,17 +61,6 @@ namespace ranges {
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> &&
@@ -67,8 +68,6 @@ namespace ranges {
__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
@@ -285,7 +284,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
using type = _Sp;
};
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 11d5c9fc36bc..bea3862cd7c8 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -6,11 +6,15 @@
// 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 <__algorithm/ranges_min.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
#include <__config>
#include <__functional/bind_back.h>
#include <__fwd/span.h>
@@ -30,10 +34,10 @@
#include <__ranges/size.h>
#include <__ranges/subrange.h>
#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <concepts>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -45,7 +49,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -60,9 +64,10 @@ 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 take_view(_View __base, range_difference_t<_View> __count)
+ : __base_(std::move(__base)), __count_(__count) {
+ _LIBCPP_ASSERT(__count >= 0, "count has to be greater than or equal to zero");
+ }
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
@@ -225,6 +230,7 @@ struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
};
template <class _Iter, class _Sent, subrange_kind _Kind>
+ requires requires{typename subrange<_Iter>;}
struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
using type = subrange<_Iter>;
};
@@ -328,7 +334,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/take_while_view.h b/libcxx/include/__ranges/take_while_view.h
new file mode 100644
index 000000000000..59c0a4f82889
--- /dev/null
+++ b/libcxx/include/__ranges/take_while_view.h
@@ -0,0 +1,183 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_WHILE_VIEW_H
+#define _LIBCPP___RANGES_TAKE_WHILE_VIEW_H
+
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.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 >= 20
+
+namespace ranges {
+
+// The spec uses the unnamed requirement inside the `begin` and `end` member functions:
+// constexpr auto begin() const
+// requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>>
+// However, due to a clang-14 and clang-15 bug, the above produces a hard error when `const V` is not a range.
+// The workaround is to create a named concept and use the concept instead.
+// As of take_while_view is implemented, the clang-trunk has already fixed the bug.
+// It is OK to remove the workaround once our CI no longer uses clang-14, clang-15 based compilers,
+// because we don't actually expect a lot of vendors to ship a new libc++ with an old clang.
+template <class _View, class _Pred>
+concept __take_while_const_is_range =
+ range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>;
+
+template <class, class, bool>
+class __take_while_view_sentinel;
+
+template <view _View, class _Pred>
+ requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
+class take_while_view : public view_interface<take_while_view<_View, _Pred>> {
+ template <class, class, bool>
+ friend class __take_while_view_sentinel;
+
+ template <bool _Const>
+ using __sentinel = __take_while_view_sentinel<_View, _Pred, _Const>;
+
+ _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
+ _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI take_while_view()
+ requires default_initializable<_View> && default_initializable<_Pred>
+ = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr take_while_view(_View __base, _Pred __pred)
+ : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
+
+ _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 const _Pred& pred() const { return *__pred_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+ requires(!__simple_view<_View>)
+ {
+ return ranges::begin(__base_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+ requires __take_while_const_is_range<_View, _Pred>
+ {
+ return ranges::begin(__base_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+ requires(!__simple_view<_View>)
+ {
+ return __sentinel</*_Const=*/false>(ranges::end(__base_), std::addressof(*__pred_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+ requires __take_while_const_is_range<_View, _Pred>
+ {
+ return __sentinel</*_Const=*/true>(ranges::end(__base_), std::addressof(*__pred_));
+ }
+};
+
+template <class _Range, class _Pred>
+take_while_view(_Range&&, _Pred) -> take_while_view<views::all_t<_Range>, _Pred>;
+
+template <class _View, class _Pred, bool _Const>
+class __take_while_view_sentinel {
+ using _Base = __maybe_const<_Const, _View>;
+
+ sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+ const _Pred* __pred_ = nullptr;
+
+ template <class, class, bool>
+ friend class __take_while_view_sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI __take_while_view_sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __take_while_view_sentinel(sentinel_t<_Base> __end, const _Pred* __pred)
+ : __end_(std::move(__end)), __pred_(__pred) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __take_while_view_sentinel(__take_while_view_sentinel<_View, _Pred, !_Const> __s)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(std::move(__s.__end_)), __pred_(__s.__pred_) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool
+ operator==(const iterator_t<_Base>& __x, const __take_while_view_sentinel& __y) {
+ return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
+ }
+
+ 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 iterator_t<__maybe_const<_OtherConst, _View>>& __x, const __take_while_view_sentinel& __y) {
+ return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
+ }
+};
+
+namespace views {
+namespace __take_while {
+
+struct __fn {
+ template <class _Range, class _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
+ noexcept(noexcept(/**/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
+ -> decltype(/*--*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
+ return /*-------------*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
+ }
+
+ template <class _Pred>
+ requires constructible_from<decay_t<_Pred>, _Pred>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
+ noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
+ return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
+ }
+};
+
+} // namespace __take_while
+
+inline namespace __cpo {
+inline constexpr auto take_while = __take_while::__fn{};
+} // namespace __cpo
+} // namespace views
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___RANGES_TAKE_WHILE_VIEW_H
diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h
index c5a7128c366b..66d9e80e6e61 100644
--- a/libcxx/include/__ranges/transform_view.h
+++ b/libcxx/include/__ranges/transform_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H
#define _LIBCPP___RANGES_TRANSFORM_VIEW_H
@@ -30,6 +31,7 @@
#include <__ranges/range_adaptor.h>
#include <__ranges/size.h>
#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
#include <__utility/move.h>
@@ -41,7 +43,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -55,11 +57,31 @@ concept __transform_view_constraints =
regular_invocable<_Fn&, range_reference_t<_View>> &&
__can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;
+template <input_range _View, copy_constructible _Function, bool _IsConst>
+ requires __transform_view_constraints<_View, _Function>
+class __transform_view_iterator;
+
+template <input_range _View, copy_constructible _Function, bool _IsConst>
+ requires __transform_view_constraints<_View, _Function>
+class __transform_view_sentinel;
+
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;
+
+ template <bool _IsConst>
+ using __iterator = __transform_view_iterator<_View, _Fn, _IsConst>;
+
+ template <bool _IsConst>
+ using __sentinel = __transform_view_sentinel<_View, _Fn, _IsConst>;
+
+ template <input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_iterator;
+
+ template <input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_sentinel;
_LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
_LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
@@ -154,22 +176,23 @@ struct __transform_view_iterator_category_base<_View, _Fn> {
>;
};
-template<input_range _View, copy_constructible _Fn>
+template<input_range _View, copy_constructible _Fn, bool _Const>
requires __transform_view_constraints<_View, _Fn>
-template<bool _Const>
-class transform_view<_View, _Fn>::__iterator
+class __transform_view_iterator
: public __transform_view_iterator_category_base<_View, _Fn> {
- using _Parent = __maybe_const<_Const, transform_view>;
+ using _Parent = __maybe_const<_Const, transform_view<_View, _Fn>>;
using _Base = __maybe_const<_Const, _View>;
_Parent *__parent_ = nullptr;
- template<bool>
- friend class transform_view<_View, _Fn>::__iterator;
+ template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_iterator;
- template<bool>
- friend class transform_view<_View, _Fn>::__sentinel;
+ template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_sentinel;
public:
iterator_t<_Base> __current_ = iterator_t<_Base>();
@@ -179,17 +202,17 @@ public:
using difference_type = range_difference_t<_Base>;
_LIBCPP_HIDE_FROM_ABI
- __iterator() requires default_initializable<iterator_t<_Base>> = default;
+ __transform_view_iterator() requires default_initializable<iterator_t<_Base>> = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)
+ constexpr __transform_view_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
+ // Note: `__i` should always be `__transform_view_iterator<false>`, but directly using
+ // `__transform_view_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)
+ constexpr __transform_view_iterator(__transform_view_iterator<_View, _Fn, !_Const> __i)
requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
: __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
@@ -211,7 +234,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator++() {
+ constexpr __transform_view_iterator& operator++() {
++__current_;
return *this;
}
@@ -220,7 +243,7 @@ public:
constexpr void operator++(int) { ++__current_; }
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator++(int)
+ constexpr __transform_view_iterator operator++(int)
requires forward_range<_Base>
{
auto __tmp = *this;
@@ -229,7 +252,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator--()
+ constexpr __transform_view_iterator& operator--()
requires bidirectional_range<_Base>
{
--__current_;
@@ -237,7 +260,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator operator--(int)
+ constexpr __transform_view_iterator operator--(int)
requires bidirectional_range<_Base>
{
auto __tmp = *this;
@@ -246,7 +269,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator+=(difference_type __n)
+ constexpr __transform_view_iterator& operator+=(difference_type __n)
requires random_access_range<_Base>
{
__current_ += __n;
@@ -254,7 +277,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- constexpr __iterator& operator-=(difference_type __n)
+ constexpr __transform_view_iterator& operator-=(difference_type __n)
requires random_access_range<_Base>
{
__current_ -= __n;
@@ -270,77 +293,77 @@ public:
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ friend constexpr bool operator==(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr bool operator<(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr bool operator>(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr bool operator<=(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr bool operator>=(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr auto operator<=>(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr __transform_view_iterator operator+(__transform_view_iterator __i, difference_type __n)
requires random_access_range<_Base>
{
- return __iterator{*__i.__parent_, __i.__current_ + __n};
+ return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr __iterator operator+(difference_type __n, __iterator __i)
+ friend constexpr __transform_view_iterator operator+(difference_type __n, __transform_view_iterator __i)
requires random_access_range<_Base>
{
- return __iterator{*__i.__parent_, __i.__current_ + __n};
+ return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr __iterator operator-(__iterator __i, difference_type __n)
+ friend constexpr __transform_view_iterator operator-(__transform_view_iterator __i, difference_type __n)
requires random_access_range<_Base>
{
- return __iterator{*__i.__parent_, __i.__current_ - __n};
+ return __transform_view_iterator{*__i.__parent_, __i.__current_ - __n};
}
_LIBCPP_HIDE_FROM_ABI
- friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
+ friend constexpr difference_type operator-(const __transform_view_iterator& __x, const __transform_view_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)
+ friend constexpr decltype(auto) iter_move(const __transform_view_iterator& __i)
noexcept(noexcept(*__i))
{
if constexpr (is_lvalue_reference_v<decltype(*__i)>)
@@ -350,33 +373,37 @@ public:
}
};
-template<input_range _View, copy_constructible _Fn>
+template<input_range _View, copy_constructible _Fn, bool _Const>
requires __transform_view_constraints<_View, _Fn>
-template<bool _Const>
-class transform_view<_View, _Fn>::__sentinel {
- using _Parent = __maybe_const<_Const, transform_view>;
+class __transform_view_sentinel {
+ using _Parent = __maybe_const<_Const, transform_view<_View, _Fn>>;
using _Base = __maybe_const<_Const, _View>;
+ template <bool _IsConst>
+ using __iterator = __transform_view_iterator<_View, _Fn, _IsConst>;
+
sentinel_t<_Base> __end_ = sentinel_t<_Base>();
- template<bool>
- friend class transform_view<_View, _Fn>::__iterator;
+ template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_iterator;
- template<bool>
- friend class transform_view<_View, _Fn>::__sentinel;
+ template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
+ requires __transform_view_constraints<_ViewType, _FunctionType>
+ friend class __transform_view_sentinel;
public:
_LIBCPP_HIDE_FROM_ABI
- __sentinel() = default;
+ __transform_view_sentinel() = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(__end) {}
+ constexpr explicit __transform_view_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
+ // Note: `__i` should always be `__transform_view_sentinel<false>`, but directly using
+ // `__transform_view_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)
+ constexpr __transform_view_sentinel(__transform_view_sentinel<_View, _Fn, !_Const> __i)
requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
: __end_(std::move(__i.__end_)) {}
@@ -386,7 +413,7 @@ public:
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) {
+ friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __transform_view_sentinel& __y) {
return __x.__current_ == __y.__end_;
}
@@ -394,7 +421,7 @@ public:
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) {
+ operator-(const __iterator<_OtherConst>& __x, const __transform_view_sentinel& __y) {
return __x.__current_ - __y.__end_;
}
@@ -402,7 +429,7 @@ public:
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) {
+ operator-(const __transform_view_sentinel& __x, const __iterator<_OtherConst>& __y) {
return __x.__end_ - __y.__current_;
}
};
@@ -433,7 +460,7 @@ inline namespace __cpo {
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/view_interface.h b/libcxx/include/__ranges/view_interface.h
index 4b36e02f7d6b..5581eb9c732a 100644
--- a/libcxx/include/__ranges/view_interface.h
+++ b/libcxx/include/__ranges/view_interface.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
#define _LIBCPP___RANGES_VIEW_INTERFACE_H
@@ -20,7 +21,9 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/empty.h>
-#include <type_traits>
+#include <__type_traits/is_class.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,7 +31,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -99,7 +102,7 @@ public:
constexpr auto size()
requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
{
- return ranges::end(__derived()) - ranges::begin(__derived());
+ return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
}
template<class _D2 = _Derived>
@@ -107,7 +110,7 @@ public:
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());
+ return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
}
template<class _D2 = _Derived>
@@ -167,7 +170,7 @@ public:
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/views.h b/libcxx/include/__ranges/views.h
index 8cc5ba3d2aca..d40c64ad8c02 100644
--- a/libcxx/include/__ranges/views.h
+++ b/libcxx/include/__ranges/views.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
namespace ranges {
@@ -28,7 +28,7 @@ namespace views { }
namespace views = ranges::views;
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/zip_view.h b/libcxx/include/__ranges/zip_view.h
index a8035bc79e12..5624726e13ee 100644
--- a/libcxx/include/__ranges/zip_view.h
+++ b/libcxx/include/__ranges/zip_view.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___RANGES_ZIP_VIEW_H
#define _LIBCPP___RANGES_ZIP_VIEW_H
@@ -44,7 +45,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 20
namespace ranges {
@@ -402,15 +403,15 @@ public:
_LIBCPP_HIDE_FROM_ABI
friend constexpr auto iter_move(const __iterator& __i) noexcept(
- (noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
+ (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
(is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
}
_LIBCPP_HIDE_FROM_ABI
friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
- (noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
- declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
+ (noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
+ std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
...))
requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
@@ -502,7 +503,7 @@ inline namespace __cpo {
} // namespace views
} // namespace ranges
-#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 20
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index f78167466217..7d0beda277ad 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -17,11 +17,14 @@
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
+#include <__memory/allocate_at_least.h>
#include <__memory/allocator.h>
+#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
#include <__utility/forward.h>
-#include <memory>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -34,6 +37,10 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
+// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).
+// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __end_cap_.first()). That allows
+// it to grow both in the front and back without having to move the data.
+
template <class _Tp, class _Allocator = allocator<_Tp> >
struct __split_buffer
{
@@ -43,7 +50,7 @@ private:
public:
typedef _Tp value_type;
typedef _Allocator allocator_type;
- typedef typename remove_reference<allocator_type>::type __alloc_rr;
+ typedef __libcpp_remove_reference_t<allocator_type> __alloc_rr;
typedef allocator_traits<__alloc_rr> __alloc_traits;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -59,110 +66,110 @@ public:
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;
+ typedef __add_lvalue_reference_t<allocator_type> __alloc_ref;
+ typedef __add_lvalue_reference_t<allocator_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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
explicit __split_buffer(__alloc_rr& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
explicit __split_buffer(const __alloc_rr& __a);
- __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
- ~__split_buffer();
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();
- __split_buffer(__split_buffer&& __c)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {return __end_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {return __end_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const {return __end_ == __begin_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() {return *__begin_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const {return *__begin_;}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() {return *(__end_ - 1);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const {return *(__end_ - 1);}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
template <class... _Args>
- void emplace_back(_Args&&... __args);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() {__destruct_at_begin(__begin_+1);}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {__destruct_at_end(__end_-1);}
- void __construct_at_end(size_type __n);
- void __construct_at_end(size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
template <class _InputIter>
- __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
- __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
- _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin)
{__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_begin(pointer __new_begin, false_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_begin(pointer __new_begin, true_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{__destruct_at_end(__new_last, false_type());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
- void swap(__split_buffer& __x)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<__alloc_rr>::value);
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
{}
struct _ConstructTransaction {
- explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
: __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
}
- ~_ConstructTransaction() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
*__dest_ = __pos_;
}
pointer __pos_;
@@ -173,6 +180,7 @@ private:
};
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
bool
__split_buffer<_Tp, _Allocator>::__invariants() const
{
@@ -203,6 +211,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@@ -219,6 +228,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
@@ -231,7 +241,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
template <class _Tp, class _Allocator>
template <class _InputIter>
-__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__alloc_rr& __a = this->__alloc();
@@ -254,7 +264,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
-__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
_ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
@@ -265,6 +275,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
@@ -274,6 +285,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
@@ -282,7 +294,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
{
@@ -291,7 +304,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
{
@@ -299,6 +313,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@@ -314,6 +329,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@@ -322,6 +338,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -329,6 +346,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -336,6 +354,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__split_buffer<_Tp, _Allocator>::~__split_buffer()
{
clear();
@@ -344,6 +363,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __first_(_VSTD::move(__c.__first_)),
@@ -358,6 +378,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@@ -384,6 +405,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__split_buffer<_Tp, _Allocator>&
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -404,6 +426,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
@@ -417,6 +440,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -433,6 +457,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -460,6 +485,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
{
@@ -474,7 +500,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
}
else
{
- size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ size_type __c = std::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_));
@@ -489,6 +515,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
{
@@ -503,7 +530,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
}
else
{
- size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ size_type __c = std::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_));
@@ -519,7 +546,8 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
{
@@ -534,7 +562,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
}
else
{
- size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ size_type __c = std::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_));
@@ -549,6 +577,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
{
@@ -563,7 +592,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
}
else
{
- size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ size_type __c = std::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_));
@@ -580,6 +609,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
@@ -594,7 +624,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
else
{
- size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+ size_type __c = std::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_));
@@ -610,7 +640,8 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
diff --git a/libcxx/include/__string/char_traits.h b/libcxx/include/__string/char_traits.h
index 18ad67b28e16..622ee224f1a0 100644
--- a/libcxx/include/__string/char_traits.h
+++ b/libcxx/include/__string/char_traits.h
@@ -14,14 +14,16 @@
#include <__algorithm/find_end.h>
#include <__algorithm/find_first_of.h>
#include <__algorithm/min.h>
+#include <__compare/ordering.h>
#include <__config>
#include <__functional/hash.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iosfwd>
-#include <type_traits>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar> // for wmemcpy
@@ -37,35 +39,124 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT>
-struct _LIBCPP_TEMPLATE_VIS char_traits
+struct char_traits;
+/*
+The Standard does not define the base template for char_traits because it is impossible to provide
+a correct definition for arbitrary character types. Instead, it requires implementations to provide
+specializations for predefined character types like `char`, `wchar_t` and others. We provide this as
+exposition-only to document what members a char_traits specialization should provide:
+{
+ using char_type = _CharT;
+ using int_type = ...;
+ using off_type = ...;
+ using pos_type = ...;
+ using state_type = ...;
+
+ static void assign(char_type&, const char_type&);
+ static bool eq(char_type, char_type);
+ static bool lt(char_type, char_type);
+
+ static int compare(const char_type*, const char_type*, size_t);
+ static size_t length(const char_type*);
+ static const char_type* find(const char_type*, size_t, const char_type&);
+ static char_type* move(char_type*, const char_type*, size_t);
+ static char_type* copy(char_type*, const char_type*, size_t);
+ static char_type* assign(char_type*, size_t, char_type);
+
+ static int_type not_eof(int_type);
+ static char_type to_char_type(int_type);
+ static int_type to_int_type(char_type);
+ static bool eq_int_type(int_type, int_type);
+ static int_type eof();
+};
+*/
+
+//
+// Temporary extension to provide a base template for std::char_traits.
+// TODO: Remove in LLVM 18.
+//
+template <class _CharT>
+struct _LIBCPP_DEPRECATED_("char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it.")
+ char_traits
{
- typedef _CharT char_type;
- typedef int int_type;
- typedef streamoff off_type;
- typedef streampos pos_type;
- typedef mbstate_t state_type;
+ using char_type = _CharT;
+ using int_type = int;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
- static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
+ static inline void _LIBCPP_CONSTEXPR_SINCE_CXX17
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);
+ static _LIBCPP_CONSTEXPR_SINCE_CXX17
+ int 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;
+ }
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
+ size_t length(const char_type* __s) {
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+ }
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) {
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return nullptr;
+ }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
+ char_type* 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;
+ }
_LIBCPP_INLINE_VISIBILITY
- static _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
+ char_type* 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;
+ }
_LIBCPP_INLINE_VISIBILITY
- static _LIBCPP_CONSTEXPR_AFTER_CXX17
- char_type* assign(char_type* __s, size_t __n, char_type __a);
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
+ char_type* assign(char_type* __s, size_t __n, char_type __a) {
+ char_type* __r = __s;
+ for (; __n; --__n, ++__s)
+ assign(*__s, __a);
+ return __r;
+ }
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -80,92 +171,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
};
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;
-}
-
-template <class _CharT>
-static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
{
#ifdef _LIBCPP_COMPILER_GCC
@@ -188,45 +194,45 @@ _CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _
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;
+ using char_type = char;
+ using int_type = int;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
+#if _LIBCPP_STD_VER > 17
+ using comparison_category = strong_ordering;
+#endif
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
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 _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (__n == 0)
+ return 0;
+ return std::__constexpr_memcmp(__s1, __s2, __n);
+ }
- 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
-#ifdef _LIBCPP_COMPILER_GCC
- if (__libcpp_is_constant_evaluated()) {
- size_t __i = 0;
- for (; __s[__i] != char_type('\0'); ++__i)
- ;
- return __i;
- }
-#endif
- return __builtin_strlen(__s);
- }
+ static inline size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT {
+ return std::__constexpr_strlen(__s);
+ }
- static _LIBCPP_CONSTEXPR_AFTER_CXX14
- const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
+ static _LIBCPP_CONSTEXPR_SINCE_CXX17
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
+ if (__n == 0)
+ return nullptr;
+ return std::__constexpr_char_memchr(__s, static_cast<int>(__a), __n);
+ }
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
return std::__char_traits_move(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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");
@@ -234,7 +240,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
return __s1;
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
std::fill_n(__s, __n, __a);
return __s;
@@ -252,82 +258,51 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
{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)
- 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;
+ using char_type = wchar_t;
+ using int_type = wint_t;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
+#if _LIBCPP_STD_VER > 17
+ using comparison_category = strong_ordering;
+#endif
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
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 _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ if (__n == 0)
+ return 0;
+ return std::__constexpr_wmemcmp(__s1, __s2, __n);
+ }
+
+ static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT {
+ return std::__constexpr_wcslen(__s);
+ }
+
+ static _LIBCPP_CONSTEXPR_SINCE_CXX17
+ const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
+ if (__n == 0)
+ return nullptr;
+ return std::__constexpr_wmemchr(__s, __a, __n);
+ }
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
return std::__char_traits_move(__s1, __s2, __n);
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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");
@@ -335,7 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
return __s1;
}
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
std::fill_n(__s, __n, __a);
return __s;
@@ -352,65 +327,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
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)
- 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)
- 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)
- 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
#ifndef _LIBCPP_HAS_NO_CHAR8_T
@@ -418,11 +334,14 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
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;
+ using char_type = char8_t;
+ using int_type = unsigned int;
+ using off_type = streamoff;
+ using pos_type = u8streampos;
+ using state_type = mbstate_t;
+#if _LIBCPP_STD_VER > 17
+ using comparison_category = strong_ordering;
+#endif
static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
{__c1 = __c2;}
@@ -431,8 +350,10 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
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 _LIBCPP_HIDE_FROM_ABI constexpr int
+ compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
+ return std::__constexpr_memcmp(__s1, __s2, __n);
+ }
static constexpr
size_t length(const char_type* __s) _NOEXCEPT;
@@ -440,12 +361,12 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
_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
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
return std::__char_traits_move(__s1, __s2, __n);
}
- static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
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");
@@ -453,7 +374,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
return __s1;
}
- static _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static _LIBCPP_CONSTEXPR_SINCE_CXX20
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
std::fill_n(__s, __n, __a);
return __s;
@@ -482,24 +403,6 @@ char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
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*
@@ -519,32 +422,35 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
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;
+ using char_type = char16_t;
+ using int_type = uint_least16_t;
+ using off_type = streamoff;
+ using pos_type = u16streampos;
+ using state_type = mbstate_t;
+#if _LIBCPP_STD_VER > 17
+ using comparison_category = strong_ordering;
+#endif
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
size_t length(const char_type* __s) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
return std::__char_traits_move(__s1, __s2, __n);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static 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");
@@ -552,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
return __s1;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
std::fill_n(__s, __n, __a);
return __s;
@@ -570,7 +476,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
{return int_type(0xFFFF);}
};
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
int
char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
@@ -584,7 +490,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz
return 0;
}
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
size_t
char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
{
@@ -594,7 +500,7 @@ char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
return __len;
}
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
const char16_t*
char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
@@ -610,38 +516,41 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
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;
+ using char_type = char32_t;
+ using int_type = uint_least32_t;
+ using off_type = streamoff;
+ using pos_type = u32streampos;
+ using state_type = mbstate_t;
+#if _LIBCPP_STD_VER > 17
+ using comparison_category = strong_ordering;
+#endif
- static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+ static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
size_t length(const char_type* __s) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
return std::__char_traits_move(__s1, __s2, __n);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
std::copy_n(__s2, __n, __s1);
return __s1;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
std::fill_n(__s, __n, __a);
return __s;
@@ -659,7 +568,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
{return int_type(0xFFFFFFFF);}
};
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
int
char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
@@ -673,7 +582,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz
return 0;
}
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
size_t
char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
{
@@ -683,7 +592,7 @@ char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
return __len;
}
-inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_CONSTEXPR_SINCE_CXX17
const char32_t*
char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
@@ -700,7 +609,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
// __str_find
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
@@ -713,7 +622,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
}
template <class _CharT, class _Traits>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
+_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 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.
@@ -752,7 +661,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -762,7 +671,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
if (__n == 0) // There is nothing to search, just return __pos.
return __pos;
- const _CharT *__r = __search_substring<_CharT, _Traits>(
+ const _CharT *__r = std::__search_substring<_CharT, _Traits>(
__p + __pos, __p + __sz, __s, __s + __n);
if (__r == __p + __sz)
@@ -774,7 +683,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
// __str_rfind
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
@@ -793,7 +702,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -810,7 +719,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
// __str_find_first_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_first_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -826,7 +735,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,
// __str_find_last_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_last_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -849,7 +758,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,
// __str_find_first_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -865,7 +774,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
@@ -882,7 +791,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
// __str_find_last_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
@@ -898,7 +807,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
-inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
diff --git a/libcxx/include/__thread/poll_with_backoff.h b/libcxx/include/__thread/poll_with_backoff.h
index 0bbafd186657..d027a2779d8e 100644
--- a/libcxx/include/__thread/poll_with_backoff.h
+++ b/libcxx/include/__thread/poll_with_backoff.h
@@ -6,16 +6,14 @@
// 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 <__chrono/duration.h>
#include <__chrono/high_resolution_clock.h>
-#include <__chrono/steady_clock.h>
-#include <__chrono/time_point.h>
#include <__config>
-#include <__filesystem/file_time_type.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__thread/timed_backoff_policy.h b/libcxx/include/__thread/timed_backoff_policy.h
index 28fe75d6fd80..a54b296ae5c5 100644
--- a/libcxx/include/__thread/timed_backoff_policy.h
+++ b/libcxx/include/__thread/timed_backoff_policy.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index a7f0da972a8d..dcf2763ad646 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -13,7 +13,9 @@
#include <__availability>
#include <__chrono/convert_to_timespec.h>
#include <__chrono/duration.h>
+#include <__compare/ordering.h>
#include <__config>
+#include <__fwd/hash.h>
#include <__thread/poll_with_backoff.h>
#include <errno.h>
#include <iosfwd>
@@ -609,40 +611,28 @@ class _LIBCPP_TEMPLATE_VIS __thread_id
// 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
+ static _LIBCPP_HIDE_FROM_ABI
+ bool __lt_impl(__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);}
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __thread_id() _NOEXCEPT : __id_(0) {}
_LIBCPP_INLINE_VISIBILITY
void __reset() { __id_ = 0; }
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT;
+#if _LIBCPP_STD_VER <= 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT;
+#else // _LIBCPP_STD_VER <= 17
+ friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept;
+#endif // _LIBCPP_STD_VER <= 17
+
template<class _CharT, class _Traits>
friend
_LIBCPP_INLINE_VISIBILITY
@@ -658,6 +648,45 @@ private:
friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;
};
+inline _LIBCPP_HIDE_FROM_ABI
+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_);
+}
+
+#if _LIBCPP_STD_VER <= 17
+
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT {
+ return !(__x == __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI
+bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT {
+ return __thread_id::__lt_impl(__x.__id_, __y.__id_);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__y < __x); }
+inline _LIBCPP_HIDE_FROM_ABI bool operator>(__thread_id __x, __thread_id __y) _NOEXCEPT { return __y < __x; }
+inline _LIBCPP_HIDE_FROM_ABI bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__x < __y); }
+
+#else // _LIBCPP_STD_VER <= 17
+
+inline _LIBCPP_HIDE_FROM_ABI
+strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept {
+ if (__x == __y)
+ return strong_ordering::equal;
+ if (__thread_id::__lt_impl(__x, __y))
+ return strong_ordering::less;
+ return strong_ordering::greater;
+}
+
+#endif // _LIBCPP_STD_VER <= 17
+
namespace this_thread
{
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 59525a03047a..f5d9d595b4b2 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -14,14 +14,32 @@
#include <__assert>
#include <__config>
#include <__debug>
+#include <__functional/invoke.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/can_extract_key.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/remove_const_ref.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#include <__utility/swap.h>
#include <limits>
-#include <memory>
#include <stdexcept>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -126,7 +144,7 @@ __tree_sub_invariant(_NodePtr __x)
// __root == nullptr is a proper tree. Returns true is __root is a proper
// red black tree, else returns false.
template <class _NodePtr>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
__tree_invariant(_NodePtr __root)
{
if (__root == nullptr)
@@ -169,7 +187,7 @@ __tree_max(_NodePtr __x) _NOEXCEPT
// Returns: pointer to the next in-order node after __x.
template <class _NodePtr>
-_NodePtr
+_LIBCPP_HIDE_FROM_ABI _NodePtr
__tree_next(_NodePtr __x) _NOEXCEPT
{
_LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
@@ -211,7 +229,7 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
// Returns: pointer to a node which has no children
template <class _NodePtr>
-_NodePtr
+_LIBCPP_HIDE_FROM_ABI _NodePtr
__tree_leaf(_NodePtr __x) _NOEXCEPT
{
_LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
@@ -235,7 +253,7 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT
// Effects: Makes __x->__right_ the subtree root with __x as its left child
// while preserving in-order order.
template <class _NodePtr>
-void
+_LIBCPP_HIDE_FROM_ABI void
__tree_left_rotate(_NodePtr __x) _NOEXCEPT
{
_LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
@@ -256,7 +274,7 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
// Effects: Makes __x->__left_ the subtree root with __x as its right child
// while preserving in-order order.
template <class _NodePtr>
-void
+_LIBCPP_HIDE_FROM_ABI void
__tree_right_rotate(_NodePtr __x) _NOEXCEPT
{
_LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
@@ -282,7 +300,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
// may be different than the value passed in as __root.
template <class _NodePtr>
-void
+_LIBCPP_HIDE_FROM_ABI void
__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
{
_LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null");
@@ -352,7 +370,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
// 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
+_LIBCPP_HIDE_FROM_ABI void
__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
{
_LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");
@@ -554,7 +572,7 @@ 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> > {};
+struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};
template <class _Tp>
struct __tree_key_value_types {
@@ -632,19 +650,17 @@ 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
+ typedef __rebind_pointer_t<_VoidPtr, __node_base_type>
__node_base_pointer;
typedef __tree_end_node<__node_base_pointer> __end_node_type;
- typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type
+ typedef __rebind_pointer_t<_VoidPtr, __end_node_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;
+ typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer>
+ __parent_pointer;
#endif
private:
@@ -659,9 +675,9 @@ 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
+ typedef __rebind_pointer_t<_AllocPtr, _Mv>
__map_value_type_pointer;
- typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
+ typedef __rebind_pointer_t<_AllocPtr, const _Mv>
__const_map_value_type_pointer;
};
@@ -683,28 +699,26 @@ public:
typedef _NodePtr __node_pointer;
typedef _Tp __node_value_type;
- typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
+ typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
__node_value_type_pointer;
- typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
+ typedef __rebind_pointer_t<_VoidPtr, const __node_value_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;
+ typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer>
+ __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,
+ static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_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
+ typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >
_NodePtr;
typedef __tree_node_types<_NodePtr> type;
};
@@ -1019,7 +1033,7 @@ public:
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 __rebind_alloc<__alloc_traits, __node> __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
private:
@@ -1028,8 +1042,7 @@ private:
// 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 __rebind_alloc<__node_traits, __node_base> __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.");
@@ -1271,14 +1284,14 @@ public:
}
template <class _Vp,
- class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
+ class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique(_Vp&& __v) {
return __emplace_unique(_VSTD::forward<_Vp>(__v));
}
template <class _Vp,
- class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
+ class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
_LIBCPP_INLINE_VISIBILITY
iterator __insert_unique(const_iterator __p, _Vp&& __v) {
return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple
deleted file mode 100644
index f85036e7af1d..000000000000
--- a/libcxx/include/__tuple
+++ /dev/null
@@ -1,550 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___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> struct _LIBCPP_TEMPLATE_VIS tuple_size;
-
-#if !defined(_LIBCPP_CXX03_LANG)
-template <class _Tp, class...>
-using __enable_if_tuple_size_imp = _Tp;
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
- const _Tp,
- __enable_if_t<!is_volatile<_Tp>::value>,
- integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
- : public integral_constant<size_t, tuple_size<_Tp>::value> {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
- volatile _Tp,
- __enable_if_t<!is_const<_Tp>::value>,
- integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
- : public integral_constant<size_t, tuple_size<_Tp>::value> {};
-
-template <class _Tp>
-struct _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> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
-template <class _Tp> struct _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 <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
- using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
-
- template <size_t _Sp>
- using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
-};
-
-#if !__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)
-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>
-struct _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
-
-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;
-#endif
-
-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>
-struct _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.
-
-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;
-};
-
-template <bool ..._Preds>
-struct __all_dummy;
-
-template <bool ..._Pred>
-struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_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<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
- template <template <class...> class>
- static auto __do_test(...) -> false_type;
-
- template <class _FromArgs, class _ToArgs>
- using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
- template <class _FromArgs, class _ToArgs>
- using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
- template <class _FromArgs, class _ToArgs>
- using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
-};
-
-// __tuple_convertible
-
-template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
- bool = __tuple_like<_Up>::value>
-struct __tuple_convertible
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_convertible<_Tp, _Up, true, true>
- : 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>
-struct __tuple_constructible
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_constructible<_Tp, _Up, true, true>
- : 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>
-struct __tuple_assignable
- : public false_type {};
-
-template <class _Tp, class _Up>
-struct __tuple_assignable<_Tp, _Up, true, true>
- : 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/libcxx/include/__tuple_dir/apply_cv.h b/libcxx/include/__tuple_dir/apply_cv.h
new file mode 100644
index 000000000000..296755a1d52d
--- /dev/null
+++ b/libcxx/include/__tuple_dir/apply_cv.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___TUPLE_APPLY_CV_H
+#define _LIBCPP___TUPLE_APPLY_CV_H
+
+#include <__config>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_volatile.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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 = __libcpp_remove_reference_t<_Tp> >
+using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
+ is_lvalue_reference<_Tp>::value,
+ is_const<_RawTp>::value,
+ is_volatile<_RawTp>::value>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_APPLY_CV_H
diff --git a/libcxx/include/__tuple_dir/make_tuple_types.h b/libcxx/include/__tuple_dir/make_tuple_types.h
new file mode 100644
index 000000000000..913ff9bbd60c
--- /dev/null
+++ b/libcxx/include/__tuple_dir/make_tuple_types.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___TUPLE_MAKE_TUPLE_TYPES_H
+#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/apply_cv.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__tuple_dir/tuple_types.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_reference.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __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.
+
+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<__libcpp_remove_reference_t<_Tp> >::value,
+ size_t _Sp = 0,
+ bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>
+struct __make_tuple_types
+{
+ static_assert(_Sp <= _Ep, "__make_tuple_types input error");
+ using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
+ 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;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
diff --git a/libcxx/include/__tuple_dir/pair_like.h b/libcxx/include/__tuple_dir/pair_like.h
new file mode 100644
index 000000000000..87407ad95b6f
--- /dev/null
+++ b/libcxx/include/__tuple_dir/pair_like.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___TUPLE_PAIR_LIKE_H
+#define _LIBCPP___TUPLE_PAIR_LIKE_H
+
+#include <__config>
+#include <__tuple_dir/tuple_like.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__type_traits/remove_cvref.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+concept __pair_like = __tuple_like<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_PAIR_LIKE_H
diff --git a/libcxx/include/__tuple_dir/sfinae_helpers.h b/libcxx/include/__tuple_dir/sfinae_helpers.h
new file mode 100644
index 000000000000..fcd65a0817be
--- /dev/null
+++ b/libcxx/include/__tuple_dir/sfinae_helpers.h
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TUPLE_SFINAE_HELPERS_H
+#define _LIBCPP___TUPLE_SFINAE_HELPERS_H
+
+#include <__config>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/make_tuple_types.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_like_ext.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__tuple_dir/tuple_types.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <bool ..._Preds>
+struct __all_dummy;
+
+template <bool ..._Pred>
+struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_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<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
+ template <template <class...> class>
+ static auto __do_test(...) -> false_type;
+
+ template <class _FromArgs, class _ToArgs>
+ using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
+ template <class _FromArgs, class _ToArgs>
+ using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
+ template <class _FromArgs, class _ToArgs>
+ using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
+};
+
+// __tuple_convertible
+
+template <class _Tp, class _Up, bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
+ bool = __tuple_like_ext<_Up>::value>
+struct __tuple_convertible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_convertible<_Tp, _Up, true, true>
+ : 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_ext<__libcpp_remove_reference_t<_Tp> >::value,
+ bool = __tuple_like_ext<_Up>::value>
+struct __tuple_constructible
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_constructible<_Tp, _Up, true, true>
+ : 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_ext<__libcpp_remove_reference_t<_Tp> >::value,
+ bool = __tuple_like_ext<_Up>::value>
+struct __tuple_assignable
+ : public false_type {};
+
+template <class _Tp, class _Up>
+struct __tuple_assignable<_Tp, _Up, true, true>
+ : 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;
+};
+
+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 = __libcpp_remove_reference_t<_Tuple> >
+using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
+ __tuple_like_ext<_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_SFINAE_HELPERS_H
diff --git a/libcxx/include/__tuple_dir/tuple_element.h b/libcxx/include/__tuple_dir/tuple_element.h
new file mode 100644
index 000000000000..06f49bf500fb
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_element.h
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_TUPLE_ELEMENT_H
+#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
+
+#include <__config>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_types.h>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv.h>
+#include <__type_traits/add_volatile.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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;
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+#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
+
+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;
+#endif
+
+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;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Ip, class ..._Tp>
+using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
+#endif
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H
diff --git a/libcxx/include/__tuple_dir/tuple_indices.h b/libcxx/include/__tuple_dir/tuple_indices.h
new file mode 100644
index 000000000000..18666d5948c9
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_indices.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___TUPLE_MAKE_TUPLE_INDICES_H
+#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
+
+#include <__config>
+#include <__utility/integer_sequence.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t...> struct __tuple_indices {};
+
+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;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
diff --git a/libcxx/include/__tuple_dir/tuple_like.h b/libcxx/include/__tuple_dir/tuple_like.h
new file mode 100644
index 000000000000..dab395be616b
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_like.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___TUPLE_TUPLE_LIKE_H
+#define _LIBCPP___TUPLE_TUPLE_LIKE_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/pair.h>
+#include <__fwd/subrange.h>
+#include <__fwd/tuple.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/remove_cvref.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+struct __tuple_like_impl : false_type {};
+
+template <class... _Tp>
+struct __tuple_like_impl<tuple<_Tp...> > : true_type {};
+
+template <class _T1, class _T2>
+struct __tuple_like_impl<pair<_T1, _T2> > : true_type {};
+
+template <class _Tp, size_t _Size>
+struct __tuple_like_impl<array<_Tp, _Size> > : true_type {};
+
+template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
+struct __tuple_like_impl<ranges::subrange<_Ip, _Sp, _Kp> > : true_type {};
+
+template <class _Tp>
+concept __tuple_like = __tuple_like_impl<remove_cvref_t<_Tp>>::value;
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_LIKE_H
diff --git a/libcxx/include/__tuple_dir/tuple_like_ext.h b/libcxx/include/__tuple_dir/tuple_like_ext.h
new file mode 100644
index 000000000000..bf9869611273
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_like_ext.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___TUPLE_TUPLE_LIKE_EXT_H
+#define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
+
+#include <__config>
+#include <__fwd/array.h>
+#include <__fwd/pair.h>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/tuple_types.h>
+#include <__type_traits/integral_constant.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct __tuple_like_ext : false_type {};
+
+template <class _Tp> struct __tuple_like_ext<const _Tp> : public __tuple_like_ext<_Tp> {};
+template <class _Tp> struct __tuple_like_ext<volatile _Tp> : public __tuple_like_ext<_Tp> {};
+template <class _Tp> struct __tuple_like_ext<const volatile _Tp> : public __tuple_like_ext<_Tp> {};
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class... _Tp> struct __tuple_like_ext<tuple<_Tp...> > : true_type {};
+#endif
+
+template <class _T1, class _T2> struct __tuple_like_ext<pair<_T1, _T2> > : true_type {};
+
+template <class _Tp, size_t _Size> struct __tuple_like_ext<array<_Tp, _Size> > : true_type {};
+
+template <class... _Tp> struct __tuple_like_ext<__tuple_types<_Tp...> > : true_type {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
diff --git a/libcxx/include/__tuple_dir/tuple_size.h b/libcxx/include/__tuple_dir/tuple_size.h
new file mode 100644
index 000000000000..d551b2258cba
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_size.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___TUPLE_TUPLE_SIZE_H
+#define _LIBCPP___TUPLE_TUPLE_SIZE_H
+
+#include <__config>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/tuple_types.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_volatile.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
+
+#if !defined(_LIBCPP_CXX03_LANG)
+template <class _Tp, class...>
+using __enable_if_tuple_size_imp = _Tp;
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ const _Tp,
+ __enable_if_t<!is_volatile<_Tp>::value>,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
+ volatile _Tp,
+ __enable_if_t<!is_const<_Tp>::value>,
+ integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+ : public integral_constant<size_t, tuple_size<_Tp>::value> {};
+
+template <class _Tp>
+struct _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> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+template <class ..._Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
+ : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_SIZE_H
diff --git a/libcxx/include/__tuple_dir/tuple_types.h b/libcxx/include/__tuple_dir/tuple_types.h
new file mode 100644
index 000000000000..c5be81cce801
--- /dev/null
+++ b/libcxx/include/__tuple_dir/tuple_types.h
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_TUPLE_TYPES_H
+#define _LIBCPP___TUPLE_TUPLE_TYPES_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class ..._Tp> struct __tuple_types {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TUPLE_TUPLE_TYPES_H
diff --git a/libcxx/include/__type_traits/add_lvalue_reference.h b/libcxx/include/__type_traits/add_lvalue_reference.h
index 0d1ee4185c8c..daa5cb9e7dff 100644
--- a/libcxx/include/__type_traits/add_lvalue_reference.h
+++ b/libcxx/include/__type_traits/add_lvalue_reference.h
@@ -18,14 +18,34 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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; };
+#if __has_builtin(__add_lvalue_reference)
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
-{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
+template <class _Tp>
+using __add_lvalue_reference_t = __add_lvalue_reference(_Tp);
+
+#else
+
+template <class _Tp, bool = __libcpp_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>
+using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type;
+
+#endif // __has_builtin(__add_lvalue_reference)
+
+template <class _Tp>
+struct add_lvalue_reference {
+ using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
+};
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
+template <class _Tp> using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/add_pointer.h b/libcxx/include/__type_traits/add_pointer.h
index aea2490c5d0c..9d0c2010077b 100644
--- a/libcxx/include/__type_traits/add_pointer.h
+++ b/libcxx/include/__type_traits/add_pointer.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__type_traits/is_referenceable.h>
#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_reference.h>
@@ -21,19 +22,32 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__add_pointer)
+
+template <class _Tp>
+using __add_pointer_t = __add_pointer(_Tp);
+
+#else
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;};
+ bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
+struct __add_pointer_impl {
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* 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;};
+template <class _Tp>
+using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
+
+#endif // __has_builtin(__add_pointer)
+
+template <class _Tp>
+struct add_pointer {
+ using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
+};
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
+template <class _Tp> using add_pointer_t = __add_pointer_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/add_rvalue_reference.h b/libcxx/include/__type_traits/add_rvalue_reference.h
index b2a1428095d8..098e84c0722c 100644
--- a/libcxx/include/__type_traits/add_rvalue_reference.h
+++ b/libcxx/include/__type_traits/add_rvalue_reference.h
@@ -18,14 +18,35 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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; };
+#if __has_builtin(__add_rvalue_reference)
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
-{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
+template <class _Tp>
+using __add_rvalue_reference_t = __add_rvalue_reference(_Tp);
+
+#else
+
+template <class _Tp, bool = __libcpp_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>
+using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type;
+
+#endif // __has_builtin(__add_rvalue_reference)
+
+template <class _Tp>
+struct add_rvalue_reference {
+ using type = __add_rvalue_reference_t<_Tp>;
+};
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
+template <class _Tp>
+using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/aligned_storage.h b/libcxx/include/__type_traits/aligned_storage.h
index 9659a90ae50c..c564d582452d 100644
--- a/libcxx/include/__type_traits/aligned_storage.h
+++ b/libcxx/include/__type_traits/aligned_storage.h
@@ -54,21 +54,13 @@ 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;
+ typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, __fallback_overaligned<_Align> > 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;
+ typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type> type;
};
template <class _TL, size_t _Len> struct __find_max_align;
@@ -91,7 +83,7 @@ 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
+struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage
{
typedef typename __find_pod<__all_types, _Align>::type _Aligner;
union type
@@ -102,13 +94,17 @@ struct _LIBCPP_TEMPLATE_VIS aligned_storage
};
#if _LIBCPP_STD_VER > 11
+
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
- using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+ using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+
#endif
#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
template <size_t _Len>\
-struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
+struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
{\
struct _ALIGNAS(n) type\
{\
diff --git a/libcxx/include/__type_traits/aligned_union.h b/libcxx/include/__type_traits/aligned_union.h
index 31eb9353a9e2..2c64130da307 100644
--- a/libcxx/include/__type_traits/aligned_union.h
+++ b/libcxx/include/__type_traits/aligned_union.h
@@ -37,7 +37,7 @@ struct __static_max<_I0, _I1, _In...>
};
template <size_t _Len, class _Type0, class ..._Types>
-struct aligned_union
+struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union
{
static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
_LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
@@ -47,7 +47,8 @@ struct aligned_union
};
#if _LIBCPP_STD_VER > 11
-template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
+template <size_t _Len, class... _Types>
+using aligned_union_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_union<_Len, _Types...>::type;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/alignment_of.h b/libcxx/include/__type_traits/alignment_of.h
index 65c603058ffa..45b4cbcc2d7d 100644
--- a/libcxx/include/__type_traits/alignment_of.h
+++ b/libcxx/include/__type_traits/alignment_of.h
@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
+inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/apply_cv.h b/libcxx/include/__type_traits/apply_cv.h
index 4a5aab48a723..680ff6ac7d91 100644
--- a/libcxx/include/__type_traits/apply_cv.h
+++ b/libcxx/include/__type_traits/apply_cv.h
@@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
#include <__config>
-#include <__type_traits/integral_constant.h>
#include <__type_traits/is_const.h>
#include <__type_traits/is_volatile.h>
#include <__type_traits/remove_reference.h>
@@ -22,8 +21,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
- bool = is_volatile<typename remove_reference<_Tp>::type>::value>
+template <class _Tp, class _Up, bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
+ bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
struct __apply_cv
{
typedef _LIBCPP_NODEBUG _Up type;
diff --git a/libcxx/include/__type_traits/can_extract_key.h b/libcxx/include/__type_traits/can_extract_key.h
new file mode 100644
index 000000000000..454c56bfae9d
--- /dev/null
+++ b/libcxx/include/__type_traits/can_extract_key.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___TYPE_TRAITS_CAN_EXTRACT_KEY_H
+#define _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
+
+#include <__config>
+#include <__fwd/pair.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_const_ref.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// 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 = __remove_const_ref_t<_ValTy> >
+struct __can_extract_key
+ : __conditional_t<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, __extract_key_fail_tag> {};
+
+template <class _Pair, class _Key, class _First, class _Second>
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
+ : __conditional_t<_IsSame<__remove_const_t<_First>, _Key>::value, __extract_key_first_tag, __extract_key_fail_tag> {
+};
+
+// __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 = __remove_const_ref_t<_ValTy> >
+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 {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
diff --git a/libcxx/include/__type_traits/common_reference.h b/libcxx/include/__type_traits/common_reference.h
index 559d39858ec8..f9195865c89e 100644
--- a/libcxx/include/__type_traits/common_reference.h
+++ b/libcxx/include/__type_traits/common_reference.h
@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// Let COND_RES(X, Y) be:
template <class _Xp, class _Yp>
using __cond_res =
- decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
+ decltype(false ? std::declval<_Xp(&)()>()() : std::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
diff --git a/libcxx/include/__type_traits/common_type.h b/libcxx/include/__type_traits/common_type.h
index 55321e9936dd..6d2df6c9b3e4 100644
--- a/libcxx/include/__type_traits/common_type.h
+++ b/libcxx/include/__type_traits/common_type.h
@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#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>());
+using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());
template <class _Tp, class _Up, class = void>
struct __common_type3 {};
@@ -47,13 +47,10 @@ struct __common_type2_imp {};
// 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>
+struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> >
{
typedef _LIBCPP_NODEBUG typename decay<decltype(
- true ? declval<_Tp>() : declval<_Up>()
+ true ? std::declval<_Tp>() : std::declval<_Up>()
)>::type type;
};
@@ -82,8 +79,7 @@ struct common_type {
template <class _Tp, class _Up>
struct __common_type_impl<
- __common_types<_Tp, _Up>,
- typename __void_t<typename common_type<_Tp, _Up>::type>::type>
+ __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> >
{
typedef typename common_type<_Tp, _Up>::type type;
};
@@ -91,7 +87,7 @@ struct __common_type_impl<
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>
+ __void_t<typename common_type<_Tp, _Up>::type> >
: __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
_Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
};
diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h
index 4b1a560ddc7c..6249812a1114 100644
--- a/libcxx/include/__type_traits/conditional.h
+++ b/libcxx/include/__type_traits/conditional.h
@@ -36,17 +36,22 @@ template <bool _Cond, class _IfRes, class _ElseRes>
using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
template <bool _Bp, class _If, class _Then>
- struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
+struct _LIBCPP_TEMPLATE_VIS conditional {
+ using type _LIBCPP_NODEBUG = _If;
+};
template <class _If, class _Then>
- struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
+struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
+ using type _LIBCPP_NODEBUG = _Then;
+};
#if _LIBCPP_STD_VER > 11
template <bool _Bp, class _IfRes, class _ElseRes>
-using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
+using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type;
#endif
// Helper so we can use "conditional_t" in all language versions.
-template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
+template <bool _Bp, class _If, class _Then>
+using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/conjunction.h b/libcxx/include/__type_traits/conjunction.h
index 45fe5cdca351..0d95347e9988 100644
--- a/libcxx/include/__type_traits/conjunction.h
+++ b/libcxx/include/__type_traits/conjunction.h
@@ -20,26 +20,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 14
-
-template <class _Arg, class... _Args>
-struct __conjunction_impl {
- using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>;
-};
-
-template <class _Arg>
-struct __conjunction_impl<_Arg> {
- using type = _Arg;
-};
-
-template <class... _Args>
-struct conjunction : __conjunction_impl<true_type, _Args...>::type {};
-
-template<class... _Args>
-inline constexpr bool conjunction_v = conjunction<_Args...>::value;
-
-#endif // _LIBCPP_STD_VER > 14
-
template <class...>
using __expand_to_true = true_type;
@@ -49,8 +29,29 @@ __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
template <class...>
false_type __and_helper(...);
+// _And always performs lazy evaluation of its arguments.
+//
+// However, `_And<_Pred...>` itself will evaluate its result immediately (without having to
+// be instantiated) since it is an alias, unlike `conjunction<_Pred...>`, which is a struct.
+// If you want to defer the evaluation of `_And<_Pred...>` itself, use `_Lazy<_And, _Pred...>`.
template <class... _Pred>
-using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
+using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
+
+#if _LIBCPP_STD_VER > 14
+
+template <class...>
+struct conjunction : true_type {};
+
+template <class _Arg>
+struct conjunction<_Arg> : _Arg {};
+
+template <class _Arg, class... _Args>
+struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};
+
+template <class... _Args>
+inline constexpr bool conjunction_v = conjunction<_Args...>::value;
+
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/copy_cvref.h b/libcxx/include/__type_traits/copy_cvref.h
index 69b97ac1cb17..8ec59b95a0ad 100644
--- a/libcxx/include/__type_traits/copy_cvref.h
+++ b/libcxx/include/__type_traits/copy_cvref.h
@@ -29,13 +29,13 @@ struct __copy_cvref
template <class _From, class _To>
struct __copy_cvref<_From&, _To>
{
- using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type;
+ using type = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;
};
template <class _From, class _To>
struct __copy_cvref<_From&&, _To>
{
- using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type;
+ using type = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;
};
template <class _From, class _To>
diff --git a/libcxx/include/__type_traits/decay.h b/libcxx/include/__type_traits/decay.h
index d47ad03fe008..f45d33b8fb4b 100644
--- a/libcxx/include/__type_traits/decay.h
+++ b/libcxx/include/__type_traits/decay.h
@@ -12,7 +12,6 @@
#include <__config>
#include <__type_traits/add_pointer.h>
#include <__type_traits/conditional.h>
-#include <__type_traits/integral_constant.h>
#include <__type_traits/is_array.h>
#include <__type_traits/is_function.h>
#include <__type_traits/is_referenceable.h>
@@ -26,9 +25,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__decay)
+template <class _Tp>
+struct decay {
+ using type _LIBCPP_NODEBUG = __decay(_Tp);
+};
+#else
template <class _Up, bool>
struct __decay {
- typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
+ typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type;
};
template <class _Up>
@@ -37,12 +42,12 @@ public:
typedef _LIBCPP_NODEBUG typename conditional
<
is_array<_Up>::value,
- typename remove_extent<_Up>::type*,
+ __add_pointer_t<__remove_extent_t<_Up> >,
typename conditional
<
is_function<_Up>::value,
typename add_pointer<_Up>::type,
- typename remove_cv<_Up>::type
+ __remove_cv_t<_Up>
>::type
>::type type;
};
@@ -51,10 +56,11 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS decay
{
private:
- typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
public:
- typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
+ typedef _LIBCPP_NODEBUG typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type type;
};
+#endif // __has_builtin(__decay)
#if _LIBCPP_STD_VER > 11
template <class _Tp> using decay_t = typename decay<_Tp>::type;
diff --git a/libcxx/include/__type_traits/dependent_type.h b/libcxx/include/__type_traits/dependent_type.h
new file mode 100644
index 000000000000..db8a869820db
--- /dev/null
+++ b/libcxx/include/__type_traits/dependent_type.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___TYPE_TRAITS_DEPENDENT_TYPE_H
+#define _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, bool>
+struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
diff --git a/libcxx/include/__type_traits/disjunction.h b/libcxx/include/__type_traits/disjunction.h
index 6c6d1a8f21b6..125f168acc3a 100644
--- a/libcxx/include/__type_traits/disjunction.h
+++ b/libcxx/include/__type_traits/disjunction.h
@@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
#include <__config>
-#include <__type_traits/conditional.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -35,6 +34,12 @@ struct _OrImpl<false> {
using _Result = _Res;
};
+// _Or always performs lazy evaluation of its arguments.
+//
+// However, `_Or<_Pred...>` itself will evaluate its result immediately (without having to
+// be instantiated) since it is an alias, unlike `disjunction<_Pred...>`, which is a struct.
+// If you want to defer the evaluation of `_Or<_Pred...>` itself, use `_Lazy<_Or, _Pred...>`
+// or `disjunction<_Pred...>` directly.
template <class... _Args>
using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;
diff --git a/libcxx/include/__type_traits/has_virtual_destructor.h b/libcxx/include/__type_traits/has_virtual_destructor.h
index 1f0bd188b717..e73a2b280cb0 100644
--- a/libcxx/include/__type_traits/has_virtual_destructor.h
+++ b/libcxx/include/__type_traits/has_virtual_destructor.h
@@ -18,21 +18,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__has_virtual_destructor)
-
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;
+inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_allocator.h b/libcxx/include/__type_traits/is_allocator.h
new file mode 100644
index 000000000000..ee4154d7e4a4
--- /dev/null
+++ b/libcxx/include/__type_traits/is_allocator.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___TYPE_IS_ALLOCATOR_H
+#define _LIBCPP___TYPE_IS_ALLOCATOR_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<typename _Alloc, typename = void, typename = void>
+struct __is_allocator : false_type {};
+
+template<typename _Alloc>
+struct __is_allocator<_Alloc,
+ __void_t<typename _Alloc::value_type>,
+ __void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))>
+ >
+ : true_type {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_IS_ALLOCATOR_H
diff --git a/libcxx/include/__type_traits/is_always_bitcastable.h b/libcxx/include/__type_traits/is_always_bitcastable.h
new file mode 100644
index 000000000000..63304eb492b7
--- /dev/null
+++ b/libcxx/include/__type_traits/is_always_bitcastable.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___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_trivially_copyable.h>
+#include <__type_traits/remove_cv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Checks whether an object of type `From` can always be bit-cast to an object of type `To` and represent a valid value
+// of type `To`. In other words, `From` and `To` have the same value representation and the set of values of `From` is
+// a subset of the set of values of `To`.
+//
+// Note that types that cannot be assigned to each other using built-in assignment (e.g. arrays) might still be
+// considered bit-castable.
+template <class _From, class _To>
+struct __is_always_bitcastable {
+ using _UnqualFrom = __remove_cv_t<_From>;
+ using _UnqualTo = __remove_cv_t<_To>;
+
+ static const bool value =
+ // First, the simple case -- `From` and `To` are the same object type.
+ (is_same<_UnqualFrom, _UnqualTo>::value && is_trivially_copyable<_UnqualFrom>::value) ||
+
+ // Beyond the simple case, we say that one type is "always bit-castable" to another if:
+ // - (1) `From` and `To` have the same value representation, and in addition every possible value of `From` has
+ // a corresponding value in the `To` type (in other words, the set of values of `To` is a superset of the set of
+ // values of `From`);
+ // - (2) When the corresponding values are not the same value (as, for example, between an unsigned and a signed
+ // integer, where a large positive value of the unsigned integer corresponds to a negative value in the signed
+ // integer type), the value of `To` that results from a bitwise copy of `From` is the same what would be produced
+ // by the built-in assignment (if it were defined for the two types, to which there are minor exceptions, e.g.
+ // built-in arrays).
+ //
+ // In practice, that means:
+ // - all integral types (except `bool`, see below) -- that is, character types and `int` types, both signed and
+ // unsigned...
+ // - as well as arrays of such types...
+ // - ...that have the same size.
+ //
+ // Other trivially-copyable types can't be validly bit-cast outside of their own type:
+ // - floating-point types normally have different sizes and thus aren't bit-castable between each other (fails #1);
+ // - integral types and floating-point types use different representations, so for example bit-casting an integral
+ // `1` to `float` results in a very small less-than-one value, unlike built-in assignment that produces `1.0`
+ // (fails #2);
+ // - booleans normally use only a single bit of their object representation; bit-casting an integer to a boolean
+ // will result in a boolean object with an incorrect representation, which is undefined behavior (fails #2).
+ // Bit-casting from a boolean into an integer, however, is valid;
+ // - enumeration types may have different ranges of possible values (fails #1);
+ // - for pointers, it is not guaranteed that pointers to different types use the same set of values to represent
+ // addresses, and the conversion results are explicitly unspecified for types with different alignments
+ // (fails #1);
+ // - for structs and unions it is impossible to determine whether the set of values of one of them is a subset of
+ // the other (fails #1);
+ // - there is no need to consider `nullptr_t` for practical purposes.
+ (
+ sizeof(_From) == sizeof(_To) &&
+ is_integral<_From>::value &&
+ is_integral<_To>::value &&
+ !is_same<_UnqualTo, bool>::value
+ );
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
diff --git a/libcxx/include/__type_traits/is_assignable.h b/libcxx/include/__type_traits/is_assignable.h
index b8cb6df9df4a..13cd682f53cb 100644
--- a/libcxx/include/__type_traits/is_assignable.h
+++ b/libcxx/include/__type_traits/is_assignable.h
@@ -18,10 +18,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
-
-#if __has_builtin(__is_assignable)
-
template<class _Tp, class _Up>
struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
@@ -30,37 +26,6 @@ template <class _Tp, class _Arg>
inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
#endif
-#else // __has_builtin(__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
-{
-};
-
-template <class _Tp, class _Arg>
-struct is_assignable
- : public __is_assignable_imp<_Tp, _Arg> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Arg>
-inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
-#endif
-
-#endif // __has_builtin(__is_assignable)
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
diff --git a/libcxx/include/__type_traits/is_callable.h b/libcxx/include/__type_traits/is_callable.h
index 73f894dce94c..445373c43b9d 100644
--- a/libcxx/include/__type_traits/is_callable.h
+++ b/libcxx/include/__type_traits/is_callable.h
@@ -25,7 +25,7 @@ template<class...>
false_type __is_callable_helper(...);
template<class _Func, class... _Args>
-struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) {};
+struct __is_callable : decltype(std::__is_callable_helper<_Func, _Args...>(0)) {};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_char_like_type.h b/libcxx/include/__type_traits/is_char_like_type.h
new file mode 100644
index 000000000000..26205843047c
--- /dev/null
+++ b/libcxx/include/__type_traits/is_char_like_type.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_IS_CHAR_LIKE_TYPE_H
+#define _LIBCPP___TYPE_TRAITS_IS_CHAR_LIKE_TYPE_H
+
+#include <__config>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/is_standard_layout.h>
+#include <__type_traits/is_trivial.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT>
+using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_CHAR_LIKE_TYPE_H
diff --git a/libcxx/include/__type_traits/is_class.h b/libcxx/include/__type_traits/is_class.h
index cddaeae6e8a9..031430f6654d 100644
--- a/libcxx/include/__type_traits/is_class.h
+++ b/libcxx/include/__type_traits/is_class.h
@@ -11,8 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_union.h>
-#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_constant_evaluated.h b/libcxx/include/__type_traits/is_constant_evaluated.h
index de5ff6c43f40..ae903da3487a 100644
--- a/libcxx/include/__type_traits/is_constant_evaluated.h
+++ b/libcxx/include/__type_traits/is_constant_evaluated.h
@@ -24,7 +24,7 @@ inline constexpr bool is_constant_evaluated() noexcept {
}
#endif
-inline _LIBCPP_CONSTEXPR
+_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_constructible.h b/libcxx/include/__type_traits/is_constructible.h
index 9a96c3df13e8..cbe61b4329e3 100644
--- a/libcxx/include/__type_traits/is_constructible.h
+++ b/libcxx/include/__type_traits/is_constructible.h
@@ -25,7 +25,7 @@ struct _LIBCPP_TEMPLATE_VIS is_constructible
#if _LIBCPP_STD_VER > 14
template <class _Tp, class ..._Args>
-inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
+inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h
index 7e49cd4e6a31..5f77fd4d7064 100644
--- a/libcxx/include/__type_traits/is_convertible.h
+++ b/libcxx/include/__type_traits/is_convertible.h
@@ -40,7 +40,7 @@ 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
+ decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> : public true_type
{};
template <class _Tp, bool _IsArray = is_array<_Tp>::value,
@@ -53,7 +53,7 @@ template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true>
}
template <class _Tp,
- unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
+ unsigned = __is_convertible_imp::__is_array_function_or_void<__libcpp_remove_reference_t<_Tp> >::value>
struct __is_convertible_check
{
static const size_t __v = 0;
diff --git a/libcxx/include/__type_traits/is_copy_assignable.h b/libcxx/include/__type_traits/is_copy_assignable.h
index e46b1249459e..b3a965ff3726 100644
--- a/libcxx/include/__type_traits/is_copy_assignable.h
+++ b/libcxx/include/__type_traits/is_copy_assignable.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,9 +20,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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> {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
+ : public integral_constant<
+ bool,
+ __is_assignable(__add_lvalue_reference_t<_Tp>,
+ __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_copy_constructible.h b/libcxx/include/__type_traits/is_copy_constructible.h
index 18dc27f2ef75..053e15911b91 100644
--- a/libcxx/include/__type_traits/is_copy_constructible.h
+++ b/libcxx/include/__type_traits/is_copy_constructible.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,8 +22,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
- : public is_constructible<_Tp,
- typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
+ : public integral_constant<
+ bool,
+ __is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_default_constructible.h b/libcxx/include/__type_traits/is_default_constructible.h
index a6368413d6b4..d2180c6a8557 100644
--- a/libcxx/include/__type_traits/is_default_constructible.h
+++ b/libcxx/include/__type_traits/is_default_constructible.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_default_constructible
- : public is_constructible<_Tp>
+ : public integral_constant<bool, __is_constructible(_Tp)>
{};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
+inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_destructible.h b/libcxx/include/__type_traits/is_destructible.h
index 5e9ac5579fdd..376d74de86e9 100644
--- a/libcxx/include/__type_traits/is_destructible.h
+++ b/libcxx/include/__type_traits/is_destructible.h
@@ -48,7 +48,7 @@ template <typename _Tp>
struct __is_destructor_wellformed {
template <typename _Tp1>
static true_type __test (
- typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
+ typename __is_destructible_apply<decltype(std::declval<_Tp1&>().~_Tp1())>::type
);
template <typename _Tp1>
@@ -63,7 +63,7 @@ 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> {};
+ __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {};
template <class _Tp>
struct __destructible_imp<_Tp, true>
diff --git a/libcxx/include/__type_traits/is_enum.h b/libcxx/include/__type_traits/is_enum.h
index bf6921c88c94..4c1db415d5a6 100644
--- a/libcxx/include/__type_traits/is_enum.h
+++ b/libcxx/include/__type_traits/is_enum.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_floating_point.h b/libcxx/include/__type_traits/is_floating_point.h
index d93e5d99d07b..392844814b62 100644
--- a/libcxx/include/__type_traits/is_floating_point.h
+++ b/libcxx/include/__type_traits/is_floating_point.h
@@ -25,7 +25,7 @@ template <> struct __libcpp_is_floating_point<double> : public tru
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> {};
+ : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_implicitly_default_constructible.h b/libcxx/include/__type_traits/is_implicitly_default_constructible.h
new file mode 100644
index 000000000000..b77f94845fde
--- /dev/null
+++ b/libcxx/include/__type_traits/is_implicitly_default_constructible.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_default_constructible.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#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(std::__test_implicit_default_constructible<_Tp const&>({})), true_type>
+ : true_type
+{ };
+
+template <class _Tp>
+struct __is_implicitly_default_constructible<_Tp, decltype(std::__test_implicit_default_constructible<_Tp const&>({})), false_type>
+ : false_type
+{ };
+#endif // !C++03
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
diff --git a/libcxx/include/__type_traits/is_integral.h b/libcxx/include/__type_traits/is_integral.h
index c1c573a75e0a..4dcc1918e337 100644
--- a/libcxx/include/__type_traits/is_integral.h
+++ b/libcxx/include/__type_traits/is_integral.h
@@ -58,7 +58,7 @@ inline constexpr bool is_integral_v = __is_integral(_Tp);
#else
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
- : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
+ : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_literal_type.h b/libcxx/include/__type_traits/is_literal_type.h
index df525ecee208..be0174550593 100644
--- a/libcxx/include/__type_traits/is_literal_type.h
+++ b/libcxx/include/__type_traits/is_literal_type.h
@@ -25,7 +25,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_
#if _LIBCPP_STD_VER > 14
template <class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
+_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
#endif // _LIBCPP_STD_VER > 14
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
diff --git a/libcxx/include/__type_traits/is_member_function_pointer.h b/libcxx/include/__type_traits/is_member_function_pointer.h
index 2d2ff81e091a..c28f359d72e3 100644
--- a/libcxx/include/__type_traits/is_member_function_pointer.h
+++ b/libcxx/include/__type_traits/is_member_function_pointer.h
@@ -50,7 +50,7 @@ inline constexpr bool is_member_function_pointer_v = __is_member_function_pointe
#else // __has_builtin(__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 > {};
+ : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_func > {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_member_object_pointer.h b/libcxx/include/__type_traits/is_member_object_pointer.h
index 250a22c97440..5bab14b4bf56 100644
--- a/libcxx/include/__type_traits/is_member_object_pointer.h
+++ b/libcxx/include/__type_traits/is_member_object_pointer.h
@@ -32,7 +32,7 @@ inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_T
#else // __has_builtin(__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 > {};
+ : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_obj > {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_member_pointer.h b/libcxx/include/__type_traits/is_member_pointer.h
index 448bcc23d55e..904d845f3327 100644
--- a/libcxx/include/__type_traits/is_member_pointer.h
+++ b/libcxx/include/__type_traits/is_member_pointer.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_member_function_pointer.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -31,7 +32,7 @@ inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
#else // __has_builtin(__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 > {};
+ : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_member > {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_move_assignable.h b/libcxx/include/__type_traits/is_move_assignable.h
index 1e8aa23bea37..3c7158b2ae06 100644
--- a/libcxx/include/__type_traits/is_move_assignable.h
+++ b/libcxx/include/__type_traits/is_move_assignable.h
@@ -10,11 +10,9 @@
#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
#include <__config>
-#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,9 +20,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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> {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_move_assignable
+ : public integral_constant<
+ bool,
+ __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_move_constructible.h b/libcxx/include/__type_traits/is_move_constructible.h
index 228cee7efffa..667d10494fff 100644
--- a/libcxx/include/__type_traits/is_move_constructible.h
+++ b/libcxx/include/__type_traits/is_move_constructible.h
@@ -12,7 +12,6 @@
#include <__config>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_move_constructible
- : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)>
{};
#if _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/__type_traits/is_nothrow_assignable.h b/libcxx/include/__type_traits/is_nothrow_assignable.h
index e3ce33ece895..0cd9d5d73414 100644
--- a/libcxx/include/__type_traits/is_nothrow_assignable.h
+++ b/libcxx/include/__type_traits/is_nothrow_assignable.h
@@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
#include <__config>
-#include <__type_traits/add_const.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,39 +18,13 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__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 // __has_builtin(__is_nothrow_assignable)
-
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Arg>
-inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
+inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h
index 92d6e8343e03..8919b7933c2b 100644
--- a/libcxx/include/__type_traits/is_nothrow_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_constructible.h
@@ -11,7 +11,10 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_reference.h>
#include <__utility/declval.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,17 +24,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if __has_builtin(__is_nothrow_constructible)
-template <class _Tp, class... _Args>
+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>()...))>
+ : public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))>
{
};
@@ -40,7 +43,7 @@ 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>()))>
+ : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))>
{
};
diff --git a/libcxx/include/__type_traits/is_nothrow_convertible.h b/libcxx/include/__type_traits/is_nothrow_convertible.h
index 712b6f2cf4b8..a8ca1c4c413c 100644
--- a/libcxx/include/__type_traits/is_nothrow_convertible.h
+++ b/libcxx/include/__type_traits/is_nothrow_convertible.h
@@ -30,7 +30,7 @@ template <typename _Tp>
static void __test_noexcept(_Tp) noexcept;
template<typename _Fm, typename _To>
-static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
+static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
__is_nothrow_convertible_test();
template <typename _Fm, typename _To>
diff --git a/libcxx/include/__type_traits/is_nothrow_copy_assignable.h b/libcxx/include/__type_traits/is_nothrow_copy_assignable.h
index 8c4b8fd1628b..58f7d97a5578 100644
--- a/libcxx/include/__type_traits/is_nothrow_copy_assignable.h
+++ b/libcxx/include/__type_traits/is_nothrow_copy_assignable.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_nothrow_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,9 +20,13 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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> {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
+ : public integral_constant<
+ bool,
+ __is_nothrow_assignable(
+ __add_lvalue_reference_t<_Tp>,
+ __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_nothrow_copy_constructible.h b/libcxx/include/__type_traits/is_nothrow_copy_constructible.h
index 966df860e4b8..ce17334b3f81 100644
--- a/libcxx/include/__type_traits/is_nothrow_copy_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_copy_constructible.h
@@ -21,9 +21,22 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
+#ifdef _LIBCPP_COMPILER_GCC
+
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> {};
+ __add_lvalue_reference_t<typename add_const<_Tp>::type> > {};
+
+#else // _LIBCPP_COMPILER_GCC
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
+ : public integral_constant<
+ bool,
+ __is_nothrow_constructible(_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type)> {};
+
+#endif // _LIBCPP_COMPILER_GCC
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_nothrow_default_constructible.h b/libcxx/include/__type_traits/is_nothrow_default_constructible.h
index addf359ec3d6..91bffa5e466e 100644
--- a/libcxx/include/__type_traits/is_nothrow_default_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_default_constructible.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_nothrow_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,12 +19,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
- : public is_nothrow_constructible<_Tp>
+ : public integral_constant<bool, __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;
+inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h
index 4763ae84086a..03ebf440492d 100644
--- a/libcxx/include/__type_traits/is_nothrow_destructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_destructible.h
@@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
#include <__config>
-#include <__type_traits/add_const.h>
#include <__type_traits/integral_constant.h>
#include <__type_traits/is_destructible.h>
#include <__type_traits/is_reference.h>
@@ -37,7 +36,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>
template <class _Tp>
struct __libcpp_is_nothrow_destructible<true, _Tp>
- : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
+ : public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) >
{
};
@@ -72,7 +71,7 @@ template <class _Tp> struct __libcpp_nothrow_destructor
is_reference<_Tp>::value> {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
- : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
+ : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > {};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
diff --git a/libcxx/include/__type_traits/is_nothrow_move_assignable.h b/libcxx/include/__type_traits/is_nothrow_move_assignable.h
index 44cea1f9cd56..18dcc9b232c6 100644
--- a/libcxx/include/__type_traits/is_nothrow_move_assignable.h
+++ b/libcxx/include/__type_traits/is_nothrow_move_assignable.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_nothrow_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,10 +20,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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>
- {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
+ : public integral_constant<
+ bool,
+ __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
+};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_nothrow_move_constructible.h b/libcxx/include/__type_traits/is_nothrow_move_constructible.h
index e3b1171a4826..ad8222a0e4c0 100644
--- a/libcxx/include/__type_traits/is_nothrow_move_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_move_constructible.h
@@ -20,10 +20,21 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
+#ifndef _LIBCPP_COMPILER_GCC
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
+ : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)>
+ {};
+
+#else // _LIBCPP_COMPILER_GCC
+
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
- : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+ : public is_nothrow_constructible<_Tp, __add_rvalue_reference_t<_Tp> >
{};
+#endif // _LIBCPP_COMPILER_GCC
+
#if _LIBCPP_STD_VER > 14
template <class _Tp>
inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
diff --git a/libcxx/include/__type_traits/is_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h
index f81cb9aadb2f..4864cee11a10 100644
--- a/libcxx/include/__type_traits/is_null_pointer.h
+++ b/libcxx/include/__type_traits/is_null_pointer.h
@@ -24,11 +24,11 @@ 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> {};
+ : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
#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> {};
+ : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_pod.h b/libcxx/include/__type_traits/is_pod.h
index 497060e00557..c1d00b269f00 100644
--- a/libcxx/include/__type_traits/is_pod.h
+++ b/libcxx/include/__type_traits/is_pod.h
@@ -18,24 +18,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__is_pod)
-
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 // __has_builtin(__is_pod)
-
#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr bool is_pod_v = is_pod<_Tp>::value;
+inline constexpr bool is_pod_v = __is_pod(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_pointer.h b/libcxx/include/__type_traits/is_pointer.h
index 63c82ae4715c..3c0ad04892a2 100644
--- a/libcxx/include/__type_traits/is_pointer.h
+++ b/libcxx/include/__type_traits/is_pointer.h
@@ -43,7 +43,7 @@ template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretai
#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> {};
+ : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<__remove_cv_t<_Tp> >::type> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_reference_wrapper.h b/libcxx/include/__type_traits/is_reference_wrapper.h
index cd391bb07e78..d187eec1e132 100644
--- a/libcxx/include/__type_traits/is_reference_wrapper.h
+++ b/libcxx/include/__type_traits/is_reference_wrapper.h
@@ -24,7 +24,7 @@ template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
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> {};
+ : public __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {};
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_referenceable.h b/libcxx/include/__type_traits/is_referenceable.h
index b97631cc39dd..4b34ec257231 100644
--- a/libcxx/include/__type_traits/is_referenceable.h
+++ b/libcxx/include/__type_traits/is_referenceable.h
@@ -19,14 +19,22 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-struct __is_referenceable_impl {
- template <class _Tp> static _Tp& __test(int);
- template <class _Tp> static false_type __test(...);
+#if __has_builtin(__is_referenceable)
+template <class _Tp>
+struct __libcpp_is_referenceable : integral_constant<bool, __is_referenceable(_Tp)> {};
+#else
+struct __libcpp_is_referenceable_impl {
+ template <class _Tp>
+ static _Tp& __test(int);
+ template <class _Tp>
+ static false_type __test(...);
};
template <class _Tp>
-struct __is_referenceable : integral_constant<bool,
- _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {};
+struct __libcpp_is_referenceable
+ : integral_constant<bool, _IsNotSame<decltype(__libcpp_is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {
+};
+#endif // __has_builtin(__is_referenceable)
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h
index ee856dbbfec7..b4dc70b5d835 100644
--- a/libcxx/include/__type_traits/is_scalar.h
+++ b/libcxx/include/__type_traits/is_scalar.h
@@ -14,6 +14,7 @@
#include <__type_traits/is_arithmetic.h>
#include <__type_traits/is_enum.h>
#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_null_pointer.h>
#include <__type_traits/is_pointer.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__type_traits/is_signed.h b/libcxx/include/__type_traits/is_signed.h
index e9722c9b2192..aa42a4e420da 100644
--- a/libcxx/include/__type_traits/is_signed.h
+++ b/libcxx/include/__type_traits/is_signed.h
@@ -11,6 +11,8 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_integral.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_specialization.h b/libcxx/include/__type_traits/is_specialization.h
new file mode 100644
index 000000000000..0cc36674257c
--- /dev/null
+++ b/libcxx/include/__type_traits/is_specialization.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___TYPE_TRAITS_IS_SPECIALIZATION
+#define _LIBCPP___TYPE_TRAITS_IS_SPECIALIZATION
+
+// This contains parts of P2098R1 but is based on MSVC STL's implementation.
+//
+// The paper has been rejected
+// We will not pursue P2098R0 (std::is_specialization_of) at this time; we'd
+// like to see a solution to this problem, but it requires language evolution
+// too.
+//
+// Since it is expected a real solution will be provided in the future only the
+// minimal part is implemented.
+//
+// Note a cvref qualified _Tp is never considered a specialization.
+
+#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, template <class...> class _Template>
+inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
+
+template <template <class...> class _Template, class... _Args>
+inline constexpr bool __is_specialization_v<_Template<_Args...>, _Template> = true;
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SPECIALIZATION
diff --git a/libcxx/include/__type_traits/is_standard_layout.h b/libcxx/include/__type_traits/is_standard_layout.h
index 0d8b5f480f0c..12c17127482f 100644
--- a/libcxx/include/__type_traits/is_standard_layout.h
+++ b/libcxx/include/__type_traits/is_standard_layout.h
@@ -19,16 +19,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
-#if __has_builtin(__is_standard_layout)
: 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;
+inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_swappable.h b/libcxx/include/__type_traits/is_swappable.h
new file mode 100644
index 000000000000..3821de17f66e
--- /dev/null
+++ b/libcxx/include/__type_traits/is_swappable.h
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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_IS_SWAPPABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
+
+#include <__config>
+#include <__type_traits/add_lvalue_reference.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_referenceable.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/nat.h>
+#include <__utility/declval.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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_SINCE_CXX20 __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_SINCE_CXX20
+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(std::declval<_LHS>(), std::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(std::declval<_Tp>(), std::declval<_Up>()))
+ && noexcept(swap(std::declval<_Up>(), std::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_t<
+ __libcpp_is_referenceable<_Tp>::value,
+ is_swappable_with<
+ __add_lvalue_reference_t<_Tp>,
+ __add_lvalue_reference_t<_Tp> >,
+ false_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_t<
+ __libcpp_is_referenceable<_Tp>::value,
+ is_nothrow_swappable_with<
+ __add_lvalue_reference_t<_Tp>,
+ __add_lvalue_reference_t<_Tp> >,
+ false_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
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
diff --git a/libcxx/include/__type_traits/is_trivial.h b/libcxx/include/__type_traits/is_trivial.h
index 73c2093d4082..840770d7b7ef 100644
--- a/libcxx/include/__type_traits/is_trivial.h
+++ b/libcxx/include/__type_traits/is_trivial.h
@@ -19,17 +19,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
-#if __has_builtin(__is_trivial)
: 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;
+inline constexpr bool is_trivial_v = __is_trivial(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_trivially_assignable.h b/libcxx/include/__type_traits/is_trivially_assignable.h
index 01540f959efe..9ef101f04ea7 100644
--- a/libcxx/include/__type_traits/is_trivially_assignable.h
+++ b/libcxx/include/__type_traits/is_trivially_assignable.h
@@ -25,7 +25,7 @@ struct is_trivially_assignable
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Arg>
-inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
+inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_trivially_constructible.h b/libcxx/include/__type_traits/is_trivially_constructible.h
index 92ea58005f84..4173e3b4cf6d 100644
--- a/libcxx/include/__type_traits/is_trivially_constructible.h
+++ b/libcxx/include/__type_traits/is_trivially_constructible.h
@@ -26,7 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
#if _LIBCPP_STD_VER > 14
template <class _Tp, class... _Args>
-inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
+inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_trivially_copy_assignable.h b/libcxx/include/__type_traits/is_trivially_copy_assignable.h
index 066d763884b0..e6a4a35dbfb3 100644
--- a/libcxx/include/__type_traits/is_trivially_copy_assignable.h
+++ b/libcxx/include/__type_traits/is_trivially_copy_assignable.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_trivially_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,9 +20,13 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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> {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
+ : public integral_constant<
+ bool,
+ __is_trivially_assignable(
+ __add_lvalue_reference_t<_Tp>,
+ __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_trivially_copy_constructible.h b/libcxx/include/__type_traits/is_trivially_copy_constructible.h
index e0c054d775d6..4bbb803a55cf 100644
--- a/libcxx/include/__type_traits/is_trivially_copy_constructible.h
+++ b/libcxx/include/__type_traits/is_trivially_copy_constructible.h
@@ -12,7 +12,6 @@
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_trivially_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
- : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
+ : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)>
{};
#if _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/__type_traits/is_trivially_copyable.h b/libcxx/include/__type_traits/is_trivially_copyable.h
index 3b7665217292..ef118bf9c49a 100644
--- a/libcxx/include/__type_traits/is_trivially_copyable.h
+++ b/libcxx/include/__type_traits/is_trivially_copyable.h
@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
#if _LIBCPP_STD_VER > 14
template <class _Tp>
-inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
+inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_trivially_default_constructible.h b/libcxx/include/__type_traits/is_trivially_default_constructible.h
index 822fa9c910c9..5c53bd55d904 100644
--- a/libcxx/include/__type_traits/is_trivially_default_constructible.h
+++ b/libcxx/include/__type_traits/is_trivially_default_constructible.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_trivially_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,12 +19,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
- : public is_trivially_constructible<_Tp>
+ : public integral_constant<bool, __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;
+inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_trivially_destructible.h b/libcxx/include/__type_traits/is_trivially_destructible.h
index 3376c3eeff43..0239fca54d7f 100644
--- a/libcxx/include/__type_traits/is_trivially_destructible.h
+++ b/libcxx/include/__type_traits/is_trivially_destructible.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_destructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -30,15 +31,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
#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 {};
+#error is_trivially_destructible is not implemented
#endif // __has_builtin(__is_trivially_destructible)
diff --git a/libcxx/include/__type_traits/is_trivially_move_assignable.h b/libcxx/include/__type_traits/is_trivially_move_assignable.h
index fc033a40dea8..8f8876f45aad 100644
--- a/libcxx/include/__type_traits/is_trivially_move_assignable.h
+++ b/libcxx/include/__type_traits/is_trivially_move_assignable.h
@@ -13,7 +13,6 @@
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_trivially_assignable.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,10 +20,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-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>
- {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
+ : public integral_constant<
+ bool,
+ __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_trivially_move_constructible.h b/libcxx/include/__type_traits/is_trivially_move_constructible.h
index be005cc26406..151bb256b95b 100644
--- a/libcxx/include/__type_traits/is_trivially_move_constructible.h
+++ b/libcxx/include/__type_traits/is_trivially_move_constructible.h
@@ -12,7 +12,6 @@
#include <__config>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_trivially_constructible.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,9 +19,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
- : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
- {};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
+ : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_union.h b/libcxx/include/__type_traits/is_union.h
index 3e8cffe034d4..998aedd1428d 100644
--- a/libcxx/include/__type_traits/is_union.h
+++ b/libcxx/include/__type_traits/is_union.h
@@ -11,7 +11,6 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_unsigned.h b/libcxx/include/__type_traits/is_unsigned.h
index 17cd909d5478..3d75409914fe 100644
--- a/libcxx/include/__type_traits/is_unsigned.h
+++ b/libcxx/include/__type_traits/is_unsigned.h
@@ -20,8 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.
-#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
+#if __has_builtin(__is_unsigned)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
diff --git a/libcxx/include/__type_traits/is_valid_expansion.h b/libcxx/include/__type_traits/is_valid_expansion.h
index c45db7509e41..db7d7e5f1d05 100644
--- a/libcxx/include/__type_traits/is_valid_expansion.h
+++ b/libcxx/include/__type_traits/is_valid_expansion.h
@@ -24,7 +24,7 @@ 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));
+using _IsValidExpansion _LIBCPP_NODEBUG = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_void.h b/libcxx/include/__type_traits/is_void.h
index 4cebf18633b2..d8ffdbd82446 100644
--- a/libcxx/include/__type_traits/is_void.h
+++ b/libcxx/include/__type_traits/is_void.h
@@ -11,6 +11,8 @@
#include <__config>
#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -31,7 +33,7 @@ inline constexpr bool is_void_v = __is_void(_Tp);
#else
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
- : public is_same<typename remove_cv<_Tp>::type, void> {};
+ : public is_same<__remove_cv_t<_Tp>, void> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
diff --git a/libcxx/include/__type_traits/make_const_lvalue_ref.h b/libcxx/include/__type_traits/make_const_lvalue_ref.h
new file mode 100644
index 000000000000..deea40d5e61a
--- /dev/null
+++ b/libcxx/include/__type_traits/make_const_lvalue_ref.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___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
+#define _LIBCPP___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
+
+#include <__config>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp>
+using __make_const_lvalue_ref = const __libcpp_remove_reference_t<_Tp>&;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
diff --git a/libcxx/include/__type_traits/make_signed.h b/libcxx/include/__type_traits/make_signed.h
index fbc31172a978..bff8744845fa 100644
--- a/libcxx/include/__type_traits/make_signed.h
+++ b/libcxx/include/__type_traits/make_signed.h
@@ -23,19 +23,25 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__make_signed)
+
+template <class _Tp>
+using __make_signed_t = __make_signed(_Tp);
+
+#else
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
+# ifndef _LIBCPP_HAS_NO_INT128
__type_list<__int128_t,
-#endif
+# endif
__nat
-#ifndef _LIBCPP_HAS_NO_INT128
+# ifndef _LIBCPP_HAS_NO_INT128
>
-#endif
+# endif
> > > > > __signed_types;
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
@@ -56,19 +62,23 @@ template <> struct __make_signed< signed long, true> {typedef long ty
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
+# 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
+# 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;
+using __make_signed_t = typename __apply_cv<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>::type;
+
+#endif // __has_builtin(__make_signed)
+
+template <class _Tp>
+struct make_signed {
+ using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>;
};
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
+template <class _Tp> using make_signed_t = __make_signed_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/make_unsigned.h b/libcxx/include/__type_traits/make_unsigned.h
index 8110a5ca9609..33c30147a613 100644
--- a/libcxx/include/__type_traits/make_unsigned.h
+++ b/libcxx/include/__type_traits/make_unsigned.h
@@ -25,19 +25,25 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__make_unsigned)
+
+template <class _Tp>
+using __make_unsigned_t = __make_unsigned(_Tp);
+
+#else
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
+# ifndef _LIBCPP_HAS_NO_INT128
__type_list<__uint128_t,
-#endif
+# endif
__nat
-#ifndef _LIBCPP_HAS_NO_INT128
+# ifndef _LIBCPP_HAS_NO_INT128
>
-#endif
+# endif
> > > > > __unsigned_types;
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
@@ -58,31 +64,35 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l
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
+# 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
+# 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;
+using __make_unsigned_t = typename __apply_cv<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>::type;
+
+#endif // __has_builtin(__make_unsigned)
+
+template <class _Tp>
+struct make_unsigned {
+ using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>;
};
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
+template <class _Tp> using make_unsigned_t = __make_unsigned_t<_Tp>;
#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);
+__make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept {
+ return static_cast<__make_unsigned_t<_Tp> >(__x);
}
#endif
template <class _Tp, class _Up>
-using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>;
+using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/maybe_const.h b/libcxx/include/__type_traits/maybe_const.h
new file mode 100644
index 000000000000..8403f6aba746
--- /dev/null
+++ b/libcxx/include/__type_traits/maybe_const.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___TYPE_TRAITS_MAYBE_CONST_H
+#define _LIBCPP___TYPE_TRAITS_MAYBE_CONST_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<bool _Const, class _Tp>
+using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_MAYBE_CONST_H
diff --git a/libcxx/include/__type_traits/negation.h b/libcxx/include/__type_traits/negation.h
index 92f205fb838e..b72f285a4d5d 100644
--- a/libcxx/include/__type_traits/negation.h
+++ b/libcxx/include/__type_traits/negation.h
@@ -25,7 +25,7 @@ struct _Not : _BoolConstant<!_Pred::value> {};
template <class _Tp>
struct negation : _Not<_Tp> {};
template<class _Tp>
-inline constexpr bool negation_v = negation<_Tp>::value;
+inline constexpr bool negation_v = !_Tp::value;
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/noexcept_move_assign_container.h b/libcxx/include/__type_traits/noexcept_move_assign_container.h
new file mode 100644
index 000000000000..35b0e51ba402
--- /dev/null
+++ b/libcxx/include/__type_traits/noexcept_move_assign_container.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___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
+#define _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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
+ > {};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
diff --git a/libcxx/include/__type_traits/promote.h b/libcxx/include/__type_traits/promote.h
index a9226a74b300..c2af327c64f7 100644
--- a/libcxx/include/__type_traits/promote.h
+++ b/libcxx/include/__type_traits/promote.h
@@ -33,10 +33,14 @@ struct __numeric_type
static double __test(unsigned long);
static double __test(long long);
static double __test(unsigned long long);
+#ifndef _LIBCPP_HAS_NO_INT128
+ static double __test(__int128_t);
+ static double __test(__uint128_t);
+#endif
static double __test(double);
static long double __test(long double);
- typedef decltype(__test(declval<_Tp>())) type;
+ typedef decltype(__test(std::declval<_Tp>())) type;
static const bool value = _IsNotSame<type, void>::value;
};
diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h
index 193d3fd129a1..9950907b2278 100644
--- a/libcxx/include/__type_traits/rank.h
+++ b/libcxx/include/__type_traits/rank.h
@@ -19,6 +19,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved
+#if __has_builtin(__array_rank) && 0
+
+template <class _Tp>
+struct rank : integral_constant<size_t, __array_rank(_Tp)> {};
+
+#else
+
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
: public integral_constant<size_t, 0> {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
@@ -26,6 +34,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
+#endif // __has_builtin(__array_rank)
+
#if _LIBCPP_STD_VER > 14
template <class _Tp>
inline constexpr size_t rank_v = rank<_Tp>::value;
diff --git a/libcxx/include/__type_traits/remove_all_extents.h b/libcxx/include/__type_traits/remove_all_extents.h
index 075e3acabb44..868cf1039f6f 100644
--- a/libcxx/include/__type_traits/remove_all_extents.h
+++ b/libcxx/include/__type_traits/remove_all_extents.h
@@ -18,6 +18,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_all_extents)
+template <class _Tp>
+struct remove_all_extents {
+ using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
+};
+
+template <class _Tp>
+using __remove_all_extents_t = __remove_all_extents(_Tp);
+#else
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
{typedef _Tp type;};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
{typedef typename remove_all_extents<_Tp>::type type;};
+template <class _Tp>
+using __remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif // __has_builtin(__remove_all_extents)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+template <class _Tp> using remove_all_extents_t = __remove_all_extents_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_const.h b/libcxx/include/__type_traits/remove_const.h
index 8efc893e965a..dc565338548e 100644
--- a/libcxx/include/__type_traits/remove_const.h
+++ b/libcxx/include/__type_traits/remove_const.h
@@ -17,10 +17,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_const)
+template <class _Tp>
+struct remove_const {
+ using type _LIBCPP_NODEBUG = __remove_const(_Tp);
+};
+
+template <class _Tp>
+using __remove_const_t = __remove_const(_Tp);
+#else
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;};
+
+template <class _Tp>
+using __remove_const_t = typename remove_const<_Tp>::type;
+#endif // __has_builtin(__remove_const)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
+template <class _Tp> using remove_const_t = __remove_const_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_const_ref.h b/libcxx/include/__type_traits/remove_const_ref.h
new file mode 100644
index 000000000000..d3b334935a5b
--- /dev/null
+++ b/libcxx/include/__type_traits/remove_const_ref.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___TYPE_TRAITS_REMOVE_CONST_REF_H
+#define _LIBCPP___TYPE_TRAITS_REMOVE_CONST_REF_H
+
+#include <__config>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+using __remove_const_ref_t = __remove_const_t<__libcpp_remove_reference_t<_Tp> >;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_REF_H
diff --git a/libcxx/include/__type_traits/remove_cv.h b/libcxx/include/__type_traits/remove_cv.h
index ce1e4e45c6d1..ea85e23b8065 100644
--- a/libcxx/include/__type_traits/remove_cv.h
+++ b/libcxx/include/__type_traits/remove_cv.h
@@ -19,10 +19,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_cv)
+template <class _Tp>
+struct remove_cv {
+ using type _LIBCPP_NODEBUG = __remove_cv(_Tp);
+};
+
+template <class _Tp>
+using __remove_cv_t = __remove_cv(_Tp);
+#else
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
-{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
+{typedef __remove_volatile_t<__remove_const_t<_Tp> > type;};
+
+template <class _Tp>
+using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >;
+#endif // __has_builtin(__remove_cv)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
+template <class _Tp> using remove_cv_t = __remove_cv_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_cvref.h b/libcxx/include/__type_traits/remove_cvref.h
index d937501fedce..e96cc6523b71 100644
--- a/libcxx/include/__type_traits/remove_cvref.h
+++ b/libcxx/include/__type_traits/remove_cvref.h
@@ -20,20 +20,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_cvref)
template <class _Tp>
-using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
+using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
+#else
+template <class _Tp>
+using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
+#endif // __has_builtin(__remove_cvref)
template <class _Tp, class _Up>
-struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
+struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {};
#if _LIBCPP_STD_VER > 17
-// remove_cvref - same as __uncvref
template <class _Tp>
struct remove_cvref {
- using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
+ using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
};
-template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
+template <class _Tp> using remove_cvref_t = __remove_cvref_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_extent.h b/libcxx/include/__type_traits/remove_extent.h
index e353de361616..79d6e573dddb 100644
--- a/libcxx/include/__type_traits/remove_extent.h
+++ b/libcxx/include/__type_traits/remove_extent.h
@@ -18,6 +18,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_extent)
+template <class _Tp>
+struct remove_extent {
+ using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
+};
+
+template <class _Tp>
+using __remove_extent_t = __remove_extent(_Tp);
+#else
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
{typedef _Tp type;};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
{typedef _Tp type;};
+template <class _Tp>
+using __remove_extent_t = typename remove_extent<_Tp>::type;
+#endif // __has_builtin(__remove_extent)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
+template <class _Tp> using remove_extent_t = __remove_extent_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_pointer.h b/libcxx/include/__type_traits/remove_pointer.h
index 50cde3829470..33ddb7103f0d 100644
--- a/libcxx/include/__type_traits/remove_pointer.h
+++ b/libcxx/include/__type_traits/remove_pointer.h
@@ -17,14 +17,27 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_pointer)
+template <class _Tp>
+struct remove_pointer {
+ using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
+};
+
+template <class _Tp>
+using __remove_pointer_t = __remove_pointer(_Tp);
+#else
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;};
+template <class _Tp>
+using __remove_pointer_t = typename remove_pointer<_Tp>::type;
+#endif // __has_builtin(__remove_pointer)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
+template <class _Tp> using remove_pointer_t = __remove_pointer_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_reference.h b/libcxx/include/__type_traits/remove_reference.h
index a69e48dc584b..b9a69749b3b9 100644
--- a/libcxx/include/__type_traits/remove_reference.h
+++ b/libcxx/include/__type_traits/remove_reference.h
@@ -18,12 +18,25 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_reference_t)
+template <class _Tp>
+struct remove_reference {
+ using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
+};
+
+template <class _Tp>
+using __libcpp_remove_reference_t = __remove_reference_t(_Tp);
+#else
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;};
+template <class _Tp>
+using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type;
+#endif // __has_builtin(__remove_reference_t)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
+template <class _Tp> using remove_reference_t = __libcpp_remove_reference_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/remove_volatile.h b/libcxx/include/__type_traits/remove_volatile.h
index 79f64c46a27d..ed6d63b41744 100644
--- a/libcxx/include/__type_traits/remove_volatile.h
+++ b/libcxx/include/__type_traits/remove_volatile.h
@@ -17,10 +17,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if __has_builtin(__remove_volatile)
+template <class _Tp>
+struct remove_volatile {
+ using type _LIBCPP_NODEBUG = __remove_volatile(_Tp);
+};
+
+template <class _Tp>
+using __remove_volatile_t = __remove_volatile(_Tp);
+#else
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;};
+
+template <class _Tp>
+using __remove_volatile_t = typename remove_volatile<_Tp>::type;
+#endif // __has_builtin(__remove_volatile)
+
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
+template <class _Tp> using remove_volatile_t = __remove_volatile_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/result_of.h b/libcxx/include/__type_traits/result_of.h
new file mode 100644
index 000000000000..804173e15e21
--- /dev/null
+++ b/libcxx/include/__type_traits/result_of.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___TYPE_TRAITS_RESULT_OF_H
+#define _LIBCPP___TYPE_TRAITS_RESULT_OF_H
+
+#include <__config>
+#include <__functional/invoke.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// result_of
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
+
+template <class _Fp, class ..._Args>
+class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
+ : public __invoke_of<_Fp, _Args...>
+{
+};
+
+#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)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPE_TRAITS_RESULT_OF_H
diff --git a/libcxx/include/__type_traits/strip_signature.h b/libcxx/include/__type_traits/strip_signature.h
new file mode 100644
index 000000000000..2bb7393c1ee7
--- /dev/null
+++ b/libcxx/include/__type_traits/strip_signature.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___TYPE_TRAITS_STRIP_SIGNATURE_H
+#define _LIBCPP___TYPE_TRAITS_STRIP_SIGNATURE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Fp>
+struct __strip_signature;
+
+# if defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
+template <class _Rp, class... _Args>
+struct __strip_signature<_Rp(*)(_Args...)> {
+ using type = _Rp(_Args...);
+};
+
+template <class _Rp, class... _Args>
+struct __strip_signature<_Rp(*)(_Args...) noexcept> {
+ using type = _Rp(_Args...);
+};
+
+# endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
+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...); };
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___TYPE_TRAITS_STRIP_SIGNATURE_H
diff --git a/libcxx/include/__type_traits/void_t.h b/libcxx/include/__type_traits/void_t.h
index a71ab5e4b07f..1ed4e4354878 100644
--- a/libcxx/include/__type_traits/void_t.h
+++ b/libcxx/include/__type_traits/void_t.h
@@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class...> using void_t = void;
#endif
-template <class>
-struct __void_t { typedef void type; };
+template <class...>
+using __void_t = void;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__utility/as_const.h b/libcxx/include/__utility/as_const.h
index be7dd8c7cf23..d4a72f43d4fa 100644
--- a/libcxx/include/__utility/as_const.h
+++ b/libcxx/include/__utility/as_const.h
@@ -10,9 +10,9 @@
#define _LIBCPP___UTILITY_AS_CONST_H
#include <__config>
+#include <__type_traits/add_const.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,7 +22,7 @@ _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; }
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
template <class _Tp>
void as_const(const _Tp&&) = delete;
diff --git a/libcxx/include/__utility/auto_cast.h b/libcxx/include/__utility/auto_cast.h
index e9079443959f..381ed0c205b2 100644
--- a/libcxx/include/__utility/auto_cast.h
+++ b/libcxx/include/__utility/auto_cast.h
@@ -11,7 +11,7 @@
#define _LIBCPP___UTILITY_AUTO_CAST_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/decay.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__utility/cmp.h b/libcxx/include/__utility/cmp.h
index 3cfd98106705..d448a1d084be 100644
--- a/libcxx/include/__utility/cmp.h
+++ b/libcxx/include/__utility/cmp.h
@@ -10,10 +10,14 @@
#define _LIBCPP___UTILITY_CMP_H
#include <__config>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/make_unsigned.h>
#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
diff --git a/libcxx/include/__utility/convert_to_integral.h b/libcxx/include/__utility/convert_to_integral.h
new file mode 100644
index 000000000000..0cc858ad1590
--- /dev/null
+++ b/libcxx/include/__utility/convert_to_integral.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___UTILITY_CONVERT_TO_INTEGRAL_H
+#define _LIBCPP___UTILITY_CONVERT_TO_INTEGRAL_H
+
+#include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/underlying_type.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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, 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> {};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename __sfinae_underlying_type<_Tp>::__promoted_type
+__convert_to_integral(_Tp __val) { return __val; }
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_CONVERT_TO_INTEGRAL_H
diff --git a/libcxx/include/__utility/declval.h b/libcxx/include/__utility/declval.h
index 97fd1eba91c6..c2f4bec13282 100644
--- a/libcxx/include/__utility/declval.h
+++ b/libcxx/include/__utility/declval.h
@@ -27,7 +27,7 @@ _Tp __declval(long);
_LIBCPP_SUPPRESS_DEPRECATED_POP
template <class _Tp>
-decltype(__declval<_Tp>(0)) declval() _NOEXCEPT;
+decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__utility/exception_guard.h b/libcxx/include/__utility/exception_guard.h
new file mode 100644
index 000000000000..737d1a69c971
--- /dev/null
+++ b/libcxx/include/__utility/exception_guard.h
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.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 <__assert>
+#include <__config>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__utility/exchange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __exception_guard 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 an
+// exception guard so that if an exception is thrown at any point during the lifetime of the
+// exception guard, it will be rolled back automatically. When the exception guard is done, one
+// must mark it as being complete so it isn't rolled back when the exception guard is destroyed.
+//
+// Exception guards are not default constructible, they can't be copied or assigned to, but
+// they can be moved around for convenience.
+//
+// __exception_guard is a no-op in -fno-exceptions mode to produce better code-gen. This means
+// that we don't provide the strong exception guarantees. However, Clang doesn't generate cleanup
+// code with exceptions disabled, so even if we wanted to provide the strong exception guarantees
+// we couldn't. This is also only relevant for constructs with a stack of
+// -fexceptions > -fno-exceptions > -fexceptions code, since the exception can't be caught where
+// exceptions are disabled. While -fexceptions > -fno-exceptions is quite common
+// (e.g. libc++.dylib > -fno-exceptions), having another layer with exceptions enabled seems a lot
+// less common, especially one that tries to catch an exception through -fno-exceptions code.
+//
+// __exception_guard 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;
+// __exception_guard guard([start=out, &out] {
+// std::destroy(start, out);
+// });
+//
+// for (; n > 0; ++iter, ++out, --n) {
+// ::new ((void*)std::addressof(*out)) value_type(*iter);
+// }
+// guard.__complete();
+// return out;
+// }
+//
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+template <class _Rollback>
+struct __exception_guard {
+ __exception_guard() = delete;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __exception_guard(_Rollback __rollback)
+ : __rollback_(std::move(__rollback)), __completed_(false) {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __exception_guard(__exception_guard&& __other)
+ _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
+ : __rollback_(std::move(__other.__rollback_)), __completed_(__other.__completed_) {
+ __other.__completed_ = true;
+ }
+
+ __exception_guard(__exception_guard const&) = delete;
+ __exception_guard& operator=(__exception_guard const&) = delete;
+ __exception_guard& operator=(__exception_guard&&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __complete() _NOEXCEPT { __completed_ = true; }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__exception_guard() {
+ if (!__completed_)
+ __rollback_();
+ }
+
+private:
+ _Rollback __rollback_;
+ bool __completed_;
+};
+#else // _LIBCPP_NO_EXCEPTIONS
+template <class _Rollback>
+struct __exception_guard {
+ __exception_guard() = delete;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard(_Rollback) {}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG __exception_guard(__exception_guard&& __other)
+ _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
+ : __completed_(__other.__completed_) {
+ __other.__completed_ = true;
+ }
+
+ __exception_guard(__exception_guard const&) = delete;
+ __exception_guard& operator=(__exception_guard const&) = delete;
+ __exception_guard& operator=(__exception_guard&&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG void __complete() _NOEXCEPT {
+ __completed_ = true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG ~__exception_guard() {
+ _LIBCPP_ASSERT(__completed_, "__exception_guard not completed with exceptions disabled");
+ }
+
+private:
+ bool __completed_ = false;
+};
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard);
+
+template <class _Rollback>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __exception_guard<_Rollback> __make_exception_guard(_Rollback __rollback) {
+ return __exception_guard<_Rollback>(std::move(__rollback));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_TRANSACTION_H
diff --git a/libcxx/include/__utility/exchange.h b/libcxx/include/__utility/exchange.h
index d9b3c151755f..8df71a17b1c0 100644
--- a/libcxx/include/__utility/exchange.h
+++ b/libcxx/include/__utility/exchange.h
@@ -10,9 +10,10 @@
#define _LIBCPP___UTILITY_EXCHANGE_H
#include <__config>
+#include <__type_traits/is_nothrow_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
#include <__utility/forward.h>
#include <__utility/move.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 11
template<class _T1, class _T2 = _T1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_T1 exchange(_T1& __obj, _T2&& __new_value)
noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value)
{
diff --git a/libcxx/include/__utility/forward.h b/libcxx/include/__utility/forward.h
index 03ca16d9f955..010f2362bdce 100644
--- a/libcxx/include/__utility/forward.h
+++ b/libcxx/include/__utility/forward.h
@@ -21,14 +21,14 @@
_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 {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
+forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __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 {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
+forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT {
static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
return static_cast<_Tp&&>(__t);
}
diff --git a/libcxx/include/__utility/forward_like.h b/libcxx/include/__utility/forward_like.h
new file mode 100644
index 000000000000..7bb0d7d2033c
--- /dev/null
+++ b/libcxx/include/__utility/forward_like.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___UTILITY_FORWARD_LIKE_H
+#define _LIBCPP___UTILITY_FORWARD_LIKE_H
+
+#include <__config>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/remove_reference.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <class _Ap, class _Bp>
+using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>;
+
+template <class _Ap, class _Bp>
+using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;
+
+template <class _Ap, class _Bp>
+using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
+
+template <class _Tp, class _Up>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept
+ -> _ForwardLike<_Tp, _Up> {
+ return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
+}
+
+#endif // _LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___UTILITY_FORWARD_LIKE_H
diff --git a/libcxx/include/__utility/in_place.h b/libcxx/include/__utility/in_place.h
index 7a4973fa0407..a3518455e257 100644
--- a/libcxx/include/__utility/in_place.h
+++ b/libcxx/include/__utility/in_place.h
@@ -10,7 +10,8 @@
#define _LIBCPP___UTILITY_IN_PLACE_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/remove_cvref.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -43,13 +44,13 @@ 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>>;
+using __is_inplace_type = __is_inplace_type_imp<__remove_cvref_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>>;
+using __is_inplace_index = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;
#endif // _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/__utility/integer_sequence.h b/libcxx/include/__utility/integer_sequence.h
index 633f1333e247..257b4301c086 100644
--- a/libcxx/include/__utility/integer_sequence.h
+++ b/libcxx/include/__utility/integer_sequence.h
@@ -10,7 +10,8 @@
#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/is_integral.h>
+#include <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,6 +19,72 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <size_t...> struct __tuple_indices;
+
+template <class _IdxType, _IdxType... _Values>
+struct __integer_sequence {
+ template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
+ using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
+
+ template <size_t _Sp>
+ using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
+};
+
+#if !__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
+
+#if __has_builtin(__make_integer_seq)
+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
+
#if _LIBCPP_STD_VER > 11
template<class _Tp, _Tp... _Ip>
@@ -71,6 +138,14 @@ template<size_t _Np>
template<class... _Tp>
using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
+# if _LIBCPP_STD_VER > 17
+// Executes __func for every element in an index_sequence.
+template <size_t... _Index, class _Function>
+_LIBCPP_HIDE_FROM_ABI constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __func) {
+ (__func.template operator()<_Index>(), ...);
+}
+# endif // _LIBCPP_STD_VER > 17
+
#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__utility/move.h b/libcxx/include/__utility/move.h
index da0d986093d6..4859c39e8bd5 100644
--- a/libcxx/include/__utility/move.h
+++ b/libcxx/include/__utility/move.h
@@ -11,7 +11,10 @@
#define _LIBCPP___UTILITY_MOVE_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/remove_reference.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,21 +23,20 @@
_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;
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
+move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
return static_cast<_Up&&>(__t);
}
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;
+ __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;
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_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
+move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {
+ return std::move(__x);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 97635c2e61b5..8151674bcc55 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -13,12 +13,35 @@
#include <__compare/synth_three_way.h>
#include <__config>
#include <__functional/unwrap_ref.h>
-#include <__tuple>
+#include <__fwd/get.h>
+#include <__fwd/tuple.h>
+#include <__tuple_dir/sfinae_helpers.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_copy_assignable.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_implicitly_default_constructible.h>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_nothrow_assignable.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_copy_assignable.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/nat.h>
#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
@@ -31,7 +54,7 @@ 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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
__non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
};
#endif
@@ -48,12 +71,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
_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
@@ -88,20 +107,26 @@ struct _LIBCPP_TEMPLATE_VIS pair
}
template <class _U1, class _U2>
- static constexpr bool __enable_explicit() {
+ static constexpr bool __is_pair_constructible() {
return is_constructible<first_type, _U1>::value
- && is_constructible<second_type, _U2>::value
- && (!is_convertible<_U1, first_type>::value
- || !is_convertible<_U2, second_type>::value);
+ && is_constructible<second_type, _U2>::value;
}
template <class _U1, class _U2>
- static constexpr bool __enable_implicit() {
- return is_constructible<first_type, _U1>::value
- && is_constructible<second_type, _U2>::value
- && is_convertible<_U1, first_type>::value
+ static constexpr bool __is_implicit() {
+ return is_convertible<_U1, first_type>::value
&& is_convertible<_U2, second_type>::value;
}
+
+ template <class _U1, class _U2>
+ static constexpr bool __enable_explicit() {
+ return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>();
+ }
+
+ template <class _U1, class _U2>
+ static constexpr bool __enable_implicit() {
+ return __is_pair_constructible<_U1, _U2>() && __is_implicit<_U1, _U2>();
+ }
};
template <bool _MaybeEnable>
@@ -127,12 +152,12 @@ struct _LIBCPP_TEMPLATE_VIS pair
};
template <class _Tuple>
- using _CheckTLC _LIBCPP_NODEBUG = typename conditional<
+ using _CheckTLC _LIBCPP_NODEBUG = __conditional_t<
__tuple_like_with_size<_Tuple, 2>::value
&& !is_same<typename decay<_Tuple>::type, pair>::value,
_CheckTupleLikeConstructor,
__check_tuple_constructor_fail
- >::type;
+ >;
template<bool _Dummy = true, typename enable_if<
_CheckArgsDep<_Dummy>::__enable_explicit_default()
@@ -153,7 +178,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
template <bool _Dummy = true, typename enable_if<
_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit pair(_T1 const& __t1, _T2 const& __t2)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
is_nothrow_copy_constructible<second_type>::value)
@@ -162,7 +187,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
template<bool _Dummy = true, typename enable_if<
_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair(_T1 const& __t1, _T2 const& __t2)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
is_nothrow_copy_constructible<second_type>::value)
@@ -176,7 +201,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
#endif
typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit pair(_U1&& __u1, _U2&& __u2)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
is_nothrow_constructible<second_type, _U2>::value))
@@ -190,16 +215,27 @@ struct _LIBCPP_TEMPLATE_VIS pair
#endif
typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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)) {}
+#if _LIBCPP_STD_VER > 20
+ template<class _U1, class _U2, __enable_if_t<
+ _CheckArgs::template __is_pair_constructible<_U1&, _U2&>()
+ >* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) pair(pair<_U1, _U2>& __p)
+ noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
+ is_nothrow_constructible<second_type, _U2&>::value))
+ : first(__p.first), second(__p.second) {}
+#endif
+
template<class _U1, class _U2, typename enable_if<
_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit pair(pair<_U1, _U2> const& __p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
is_nothrow_constructible<second_type, _U2 const&>::value))
@@ -208,7 +244,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
template<class _U1, class _U2, typename enable_if<
_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair(pair<_U1, _U2> const& __p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
is_nothrow_constructible<second_type, _U2 const&>::value))
@@ -217,7 +253,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
template<class _U1, class _U2, typename enable_if<
_CheckArgs::template __enable_explicit<_U1, _U2>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit pair(pair<_U1, _U2>&&__p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
is_nothrow_constructible<second_type, _U2&&>::value))
@@ -226,16 +262,28 @@ struct _LIBCPP_TEMPLATE_VIS pair
template<class _U1, class _U2, typename enable_if<
_CheckArgs::template __enable_implicit<_U1, _U2>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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)) {}
+#if _LIBCPP_STD_VER > 20
+ template<class _U1, class _U2, __enable_if_t<
+ _CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>()
+ >* = nullptr>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())
+ pair(const pair<_U1, _U2>&& __p)
+ noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&
+ is_nothrow_constructible<second_type, const _U2&&>::value)
+ : first(std::move(__p.first)), second(std::move(__p.second)) {}
+#endif
+
template<class _Tuple, typename enable_if<
_CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit pair(_Tuple&& __p)
: first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
@@ -243,13 +291,13 @@ struct _LIBCPP_TEMPLATE_VIS pair
template<class _Tuple, typename enable_if<
_CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
_NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
@@ -258,11 +306,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
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<
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+ pair& operator=(__conditional_t<
is_copy_assignable<first_type>::value &&
is_copy_assignable<second_type>::value,
- pair, __nat>::type const& __p)
+ pair, __nat> const& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
is_nothrow_copy_assignable<second_type>::value)
{
@@ -271,11 +319,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
return *this;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair& operator=(typename conditional<
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+ pair& operator=(__conditional_t<
is_move_assignable<first_type>::value &&
is_move_assignable<second_type>::value,
- pair, __nat>::type&& __p)
+ pair, __nat>&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value)
{
@@ -284,10 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS pair
return *this;
}
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const pair& operator=(pair const& __p) const
+ noexcept(is_nothrow_copy_assignable_v<const first_type> &&
+ is_nothrow_copy_assignable_v<const second_type>)
+ requires(is_copy_assignable_v<const first_type> &&
+ is_copy_assignable_v<const second_type>) {
+ first = __p.first;
+ second = __p.second;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const pair& operator=(pair&& __p) const
+ noexcept(is_nothrow_assignable_v<const first_type&, first_type> &&
+ is_nothrow_assignable_v<const second_type&, second_type>)
+ requires(is_assignable_v<const first_type&, first_type> &&
+ is_assignable_v<const second_type&, second_type>) {
+ first = std::forward<first_type>(__p.first);
+ second = std::forward<second_type>(__p.second);
+ return *this;
+ }
+
+ template<class _U1, class _U2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const pair& operator=(const pair<_U1, _U2>& __p) const
+ requires(is_assignable_v<const first_type&, const _U1&> &&
+ is_assignable_v<const second_type&, const _U2&>) {
+ first = __p.first;
+ second = __p.second;
+ return *this;
+ }
+
+ template<class _U1, class _U2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const pair& operator=(pair<_U1, _U2>&& __p) const
+ requires(is_assignable_v<const first_type&, _U1> &&
+ is_assignable_v<const second_type&, _U2>) {
+ first = std::forward<_U1>(__p.first);
+ second = std::forward<_U2>(__p.second);
+ return *this;
+ }
+#endif // _LIBCPP_STD_VER > 20
+
template <class _Tuple, typename enable_if<
_CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
>::type* = nullptr>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
pair& operator=(_Tuple&& __p) {
first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
@@ -295,7 +387,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
__is_nothrow_swappable<second_type>::value)
@@ -304,11 +396,23 @@ struct _LIBCPP_TEMPLATE_VIS pair
swap(first, __p.first);
swap(second, __p.second);
}
+
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ void swap(const pair& __p) const
+ noexcept(__is_nothrow_swappable<const first_type>::value &&
+ __is_nothrow_swappable<const second_type>::value)
+ {
+ using std::swap;
+ swap(first, __p.first);
+ swap(second, __p.second);
+ }
+#endif
private:
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>);
@@ -323,7 +427,7 @@ pair(_T1, _T2) -> pair<_T1, _T2>;
// [pairs.spec], specialized algorithms
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -348,7 +452,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
#else // _LIBCPP_STD_VER > 17
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -356,7 +460,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -364,7 +468,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -372,7 +476,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -380,7 +484,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -406,7 +510,7 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
#endif // _LIBCPP_STD_VER > 20
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_swappable<_T1>::value &&
@@ -420,10 +524,20 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
__x.swap(__y);
}
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 20
+template <class _T1, class _T2>
+ requires (__is_swappable<const _T1>::value &&
+ __is_swappable<const _T2>::value)
+_LIBCPP_HIDE_FROM_ABI constexpr
+void swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
+ noexcept(noexcept(__x.swap(__y)))
+{
+ __x.swap(__y);
+}
+#endif
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
make_pair(_T1&& __t1, _T2&& __t2)
{
@@ -431,18 +545,6 @@ make_pair(_T1&& __t1, _T2&& __t2)
(_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> {};
@@ -472,29 +574,27 @@ struct __get_pair<0>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_T1&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _T1&&
get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
-#endif // _LIBCPP_CXX03_LANG
};
template <>
@@ -502,33 +602,31 @@ struct __get_pair<1>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_T2&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>& __p) _NOEXCEPT
{
@@ -536,16 +634,15 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT
}
template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT
{
@@ -553,13 +650,12 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
}
template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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>
@@ -618,7 +714,7 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
return __get_pair<1>::get(_VSTD::move(__p));
}
-#endif
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__utility/rel_ops.h b/libcxx/include/__utility/rel_ops.h
index 2577e94e91f6..5f8d42c0b2a3 100644
--- a/libcxx/include/__utility/rel_ops.h
+++ b/libcxx/include/__utility/rel_ops.h
@@ -10,9 +10,6 @@
#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
diff --git a/libcxx/include/__utility/swap.h b/libcxx/include/__utility/swap.h
index f9e7f36678ba..0843b35a8b58 100644
--- a/libcxx/include/__utility/swap.h
+++ b/libcxx/include/__utility/swap.h
@@ -10,10 +10,14 @@
#define _LIBCPP___UTILITY_SWAP_H
#include <__config>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_swappable.h>
#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
@@ -30,7 +34,7 @@ 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)
+inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
@@ -38,7 +42,7 @@ inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CX
}
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if<__is_swappable<_Tp>::value>::type
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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]);
diff --git a/libcxx/include/__utility/to_underlying.h b/libcxx/include/__utility/to_underlying.h
index 3428406e8d3a..a194d3ef28c5 100644
--- a/libcxx/include/__utility/to_underlying.h
+++ b/libcxx/include/__utility/to_underlying.h
@@ -11,7 +11,7 @@
#define _LIBCPP___UTILITY_TO_UNDERLYING_H
#include <__config>
-#include <type_traits>
+#include <__type_traits/underlying_type.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__utility/transaction.h b/libcxx/include/__utility/transaction.h
deleted file mode 100644
index e2cc43820845..000000000000
--- a/libcxx/include/__utility/transaction.h
+++ /dev/null
@@ -1,96 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.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
- _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__transaction() {
- if (!__completed_)
- __rollback_();
- }
-
-private:
- _Rollback __rollback_;
- bool __completed_;
-};
-
-template <class _Rollback>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) {
- return __transaction<_Rollback>(std::move(__rollback));
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___UTILITY_TRANSACTION_H
diff --git a/libcxx/include/__utility/unreachable.h b/libcxx/include/__utility/unreachable.h
index 485edb227c92..d93e60b10b86 100644
--- a/libcxx/include/__utility/unreachable.h
+++ b/libcxx/include/__utility/unreachable.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___UTILITY_UNREACHABLE_H
#define _LIBCPP___UTILITY_UNREACHABLE_H
+#include <__assert>
#include <__config>
-#include <cstdlib>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,21 +18,17 @@
_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
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {
+ _LIBCPP_ASSERT(false, "std::unreachable() was reached");
+ __builtin_unreachable();
}
#if _LIBCPP_STD_VER > 20
[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
-#endif // _LIBCPP_STD_VER > 20
+#endif
_LIBCPP_END_NAMESPACE_STD
-#endif
+#endif // _LIBCPP___UTILITY_UNREACHABLE_H
diff --git a/libcxx/include/__variant/monostate.h b/libcxx/include/__variant/monostate.h
index b389c3b56b36..b3b4597dd985 100644
--- a/libcxx/include/__variant/monostate.h
+++ b/libcxx/include/__variant/monostate.h
@@ -10,6 +10,7 @@
#ifndef _LIBCPP___VARIANT_MONOSTATE_H
#define _LIBCPP___VARIANT_MONOSTATE_H
+#include <__compare/ordering.h>
#include <__config>
#include <__functional/hash.h>
#include <cstddef>
@@ -24,31 +25,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS monostate {};
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<(monostate, monostate) noexcept { return false; }
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(monostate, monostate) noexcept { return true; }
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>(monostate, monostate) noexcept { return false; }
+# if _LIBCPP_STD_VER > 17
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(monostate, monostate) noexcept { return true; }
+_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
+ return strong_ordering::equal;
+}
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(monostate, monostate) noexcept { return true; }
+# else // _LIBCPP_STD_VER > 17
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(monostate, monostate) noexcept { return true; }
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(monostate, monostate) noexcept { return false; }
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(monostate, monostate) noexcept { return false; }
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(monostate, monostate) noexcept { return false; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(monostate, monostate) noexcept { return false; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(monostate, monostate) noexcept { return true; }
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(monostate, monostate) noexcept { return true; }
+
+# endif // _LIBCPP_STD_VER > 17
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 {
+ inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {
return 66740831; // return a fundamentally attractive random value.
}
};
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
new file mode 100644
index 000000000000..a16d75d5ac4c
--- /dev/null
+++ b/libcxx/include/__verbose_abort
@@ -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___VERBOSE_ABORT
+#define _LIBCPP___VERBOSE_ABORT
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// This function should never be called directly from the code -- it should only be called through
+// the _LIBCPP_VERBOSE_ABORT macro.
+_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+void __libcpp_verbose_abort(const char *__format, ...);
+
+// _LIBCPP_VERBOSE_ABORT(format, args...)
+//
+// This macro is used to abort the program abnormally while providing additional diagnostic information.
+//
+// The first argument is a printf-style format string, and the remaining arguments are values to format
+// into the format-string. This macro can be customized by users to provide fine-grained control over
+// how verbose termination is triggered.
+//
+// If the user does not supply their own version of the _LIBCPP_VERBOSE_ABORT macro, we pick the default
+// behavior based on whether we know the built library we're running against provides support for the
+// verbose termination handler or not. If it does, we call it. If it doesn't, we call __builtin_abort to
+// make sure that the program terminates but without taking any complex dependencies in this header.
+#if !defined(_LIBCPP_VERBOSE_ABORT)
+
+// Support _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED until LLVM 18, but tell people
+// to move to customizing _LIBCPP_VERBOSE_ABORT instead.
+# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
+# undef _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
+# warning _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED is deprecated, please customize _LIBCPP_VERBOSE_ABORT instead
+# endif
+
+# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY)
+# define _LIBCPP_VERBOSE_ABORT(...) __builtin_abort()
+# else
+# define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
+# endif
+#endif // !defined(_LIBCPP_VERBOSE_ABORT)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___VERBOSE_ABORT
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 197b3b1043bb..cb2d27cbc80c 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -446,6 +446,25 @@ namespace ranges {
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+ template<input_iterator I1, sentinel_for<I1> S1,
+ random_access_iterator I2, sentinel_for<I2> S2,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
+ constexpr partial_sort_copy_result<I1, I2>
+ partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<input_range R1, random_access_range R2, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
+ sortable<iterator_t<R2>, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>>
+ constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
@@ -574,6 +593,11 @@ namespace ranges {
constexpr borrowed_iterator_t<R>
ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
+ template<class T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr const T&
+ ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}); // since C++20
+
template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
class Proj1 = identity, class Proj2 = identity,
indirect_strict_weak_order<projected<I1, Proj1>,
@@ -726,6 +750,13 @@ namespace ranges {
constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
ranges::reverse_copy(R&& r, O result); // since C++20
+ template<permutable I, sentinel_for<I> S>
+ constexpr subrange<I> rotate(I first, I middle, S last); // since C++20
+
+ template<forward_range R>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle); // Since C++20
+
template <class _InIter, class _OutIter>
using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
@@ -739,6 +770,18 @@ namespace ranges {
constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
+ requires (forward_iterator<I> || random_access_iterator<O>) &&
+ indirectly_copyable<I, O> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Gen>
+ requires (forward_range<R> || random_access_iterator<O>) &&
+ indirectly_copyable<iterator_t<R>, O> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // Since C++20
+
template<random_access_iterator I, sentinel_for<I> S, class Gen>
requires permutable<I> &&
uniform_random_bit_generator<remove_reference_t<Gen>>
@@ -750,6 +793,21 @@ namespace ranges {
borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20
template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
+ sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
+ indirect_equivalence_relation<projected<I1, Proj1>,
+ projected<I2, Proj2>> Pred = ranges::equal_to>
+ constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
+ Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<forward_range R1, forward_range R2,
+ class Proj1 = identity, class Proj2 = identity,
+ indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
+ constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
sentinel_for<I2> S2, class Pred = ranges::equal_to,
class Proj1 = identity, class Proj2 = identity>
requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
@@ -803,7 +861,7 @@ namespace ranges {
set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
Comp comp = {}, Proj1 proj1 = {},
Proj2 proj2 = {}); // since C++20
-
+
template<input_range R1, input_range R2, weakly_incrementable O,
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
@@ -816,13 +874,13 @@ namespace ranges {
indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
constexpr subrange<I>
equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
-
+
template<forward_range R, class T, class Proj = identity,
indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
ranges::less>
constexpr borrowed_subrange_t<R>
equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
-
+
template<class I1, class I2, class O>
using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
@@ -847,15 +905,154 @@ namespace ranges {
ranges::less>
constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
-
+
template<input_range R1, input_range R2, class Proj1 = identity,
class Proj2 = identity,
indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ borrowed_iterator_t<R>
+ inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
+ Proj proj = {}); // Since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<I, O> &&
+ (forward_iterator<I> ||
+ (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<I, O>)
+ constexpr unique_copy_result<I, O>
+ unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ (forward_iterator<iterator_t<R>> ||
+ (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<iterator_t<R>, O>)
+ constexpr unique_copy_result<borrowed_iterator_t<R>, O>
+ unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
+ class Proj = identity>
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr remove_copy_result<I, O>
+ remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class T, class Proj = identity>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ indirect_binary_predicate<ranges::equal_to,
+ projected<iterator_t<R>, Proj>, const T*>
+ constexpr remove_copy_result<borrowed_iterator_t<R>, O>
+ remove_copy(R&& r, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_if_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr remove_copy_if_result<I, O>
+ remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
+ remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using replace_copy_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T1, class T2,
+ output_iterator<const T2&> O, class Proj = identity>
+ requires indirectly_copyable<I, O> &&
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
+ constexpr replace_copy_result<I, O>
+ replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<input_range R, class T1, class T2, output_iterator<const T2&> O,
+ class Proj = identity>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ indirect_binary_predicate<ranges::equal_to,
+ projected<iterator_t<R>, Proj>, const T1*>
+ constexpr replace_copy_result<borrowed_iterator_t<R>, O>
+ replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using replace_copy_if_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr replace_copy_if_result<I, O>
+ replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
+ replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<class I>
+ using prev_permutation_result = in_found_result<I>; // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr ranges::prev_permutation_result<I>
+ ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
+ ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<class I>
+ using next_permutation_result = in_found_result<I>; // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr ranges::next_permutation_result<I>
+ ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
+ ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
}
+template <class InputIterator, class Predicate>
constexpr bool // constexpr in C++20
all_of(InputIterator first, InputIterator last, Predicate pred);
@@ -1507,12 +1704,9 @@ template <class BidirectionalIterator, class Compare>
*/
#include <__assert> // all public C++ headers provide the assertion handler
-#include <__bits>
#include <__config>
#include <__debug>
#include <cstddef>
-#include <cstring>
-#include <memory>
#include <type_traits>
#include <version>
@@ -1587,6 +1781,7 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_all_of.h>
#include <__algorithm/ranges_any_of.h>
#include <__algorithm/ranges_binary_search.h>
+#include <__algorithm/ranges_clamp.h>
#include <__algorithm/ranges_copy.h>
#include <__algorithm/ranges_copy_backward.h>
#include <__algorithm/ranges_copy_if.h>
@@ -1607,9 +1802,11 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_generate.h>
#include <__algorithm/ranges_generate_n.h>
#include <__algorithm/ranges_includes.h>
+#include <__algorithm/ranges_inplace_merge.h>
#include <__algorithm/ranges_is_heap.h>
#include <__algorithm/ranges_is_heap_until.h>
#include <__algorithm/ranges_is_partitioned.h>
+#include <__algorithm/ranges_is_permutation.h>
#include <__algorithm/ranges_is_sorted.h>
#include <__algorithm/ranges_is_sorted_until.h>
#include <__algorithm/ranges_lexicographical_compare.h>
@@ -1625,21 +1822,30 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_mismatch.h>
#include <__algorithm/ranges_move.h>
#include <__algorithm/ranges_move_backward.h>
+#include <__algorithm/ranges_next_permutation.h>
#include <__algorithm/ranges_none_of.h>
#include <__algorithm/ranges_nth_element.h>
#include <__algorithm/ranges_partial_sort.h>
+#include <__algorithm/ranges_partial_sort_copy.h>
#include <__algorithm/ranges_partition.h>
#include <__algorithm/ranges_partition_copy.h>
#include <__algorithm/ranges_partition_point.h>
#include <__algorithm/ranges_pop_heap.h>
+#include <__algorithm/ranges_prev_permutation.h>
#include <__algorithm/ranges_push_heap.h>
#include <__algorithm/ranges_remove.h>
+#include <__algorithm/ranges_remove_copy.h>
+#include <__algorithm/ranges_remove_copy_if.h>
#include <__algorithm/ranges_remove_if.h>
#include <__algorithm/ranges_replace.h>
+#include <__algorithm/ranges_replace_copy.h>
+#include <__algorithm/ranges_replace_copy_if.h>
#include <__algorithm/ranges_replace_if.h>
#include <__algorithm/ranges_reverse.h>
#include <__algorithm/ranges_reverse_copy.h>
+#include <__algorithm/ranges_rotate.h>
#include <__algorithm/ranges_rotate_copy.h>
+#include <__algorithm/ranges_sample.h>
#include <__algorithm/ranges_search.h>
#include <__algorithm/ranges_search_n.h>
#include <__algorithm/ranges_set_difference.h>
@@ -1653,6 +1859,8 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_stable_sort.h>
#include <__algorithm/ranges_swap_ranges.h>
#include <__algorithm/ranges_transform.h>
+#include <__algorithm/ranges_unique.h>
+#include <__algorithm/ranges_unique_copy.h>
#include <__algorithm/ranges_upper_bound.h>
#include <__algorithm/remove.h>
#include <__algorithm/remove_copy.h>
@@ -1688,13 +1896,9 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/unwrap_iter.h>
#include <__algorithm/upper_bound.h>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-# include <iterator>
-# include <utility>
-#endif
-
// standard-mandated includes
+
+// [algorithm.syn]
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1702,7 +1906,21 @@ template <class BidirectionalIterator, class Compare>
#endif
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
-# include <__pstl_algorithm>
+# include <__pstl_algorithm>
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+# include <chrono>
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <cstring>
+# include <iterator>
+# include <memory>
+# include <stdexcept>
+# include <utility>
#endif
#endif // _LIBCPP_ALGORITHM
diff --git a/libcxx/include/any b/libcxx/include/any
index 66f7488e5441..92cbc9a6c92d 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -83,21 +83,20 @@ namespace std {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
+#include <__memory/allocator.h>
+#include <__memory/allocator_destructor.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/unique_ptr.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
#include <cstdlib>
#include <initializer_list>
-#include <memory>
#include <type_traits>
#include <typeinfo>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -106,7 +105,7 @@ namespace std {
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
{
public:
- virtual const char* what() const _NOEXCEPT;
+ const char* what() const _NOEXCEPT override;
};
} // namespace std
@@ -139,7 +138,9 @@ add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
namespace __any_imp
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
template <class _Tp>
using _IsSmallObject = integral_constant<bool
@@ -194,18 +195,18 @@ class _LIBCPP_TEMPLATE_VIS any
public:
// construct/destruct
_LIBCPP_INLINE_VISIBILITY
- constexpr any() _NOEXCEPT : __h(nullptr) {}
+ constexpr any() _NOEXCEPT : __h_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY
- any(any const & __other) : __h(nullptr)
+ any(any const & __other) : __h_(nullptr)
{
- if (__other.__h) __other.__call(_Action::_Copy, this);
+ if (__other.__h_) __other.__call(_Action::_Copy, this);
}
_LIBCPP_INLINE_VISIBILITY
- any(any && __other) _NOEXCEPT : __h(nullptr)
+ any(any && __other) _NOEXCEPT : __h_(nullptr)
{
- if (__other.__h) __other.__call(_Action::_Move, this);
+ if (__other.__h_) __other.__call(_Action::_Move, this);
}
template <
@@ -284,19 +285,19 @@ public:
// 6.3.3 any modifiers
_LIBCPP_INLINE_VISIBILITY
- void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
+ 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; }
+ bool has_value() const _NOEXCEPT { return __h_ != nullptr; }
#if !defined(_LIBCPP_NO_RTTI)
_LIBCPP_INLINE_VISIBILITY
const type_info & type() const _NOEXCEPT {
- if (__h) {
+ if (__h_) {
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
} else {
return typeid(void);
@@ -320,7 +321,7 @@ private:
type_info const * __info = nullptr,
const void* __fallback_info = nullptr) const
{
- return __h(__a, this, __other, __info, __fallback_info);
+ return __h_(__a, this, __other, __info, __fallback_info);
}
_LIBCPP_INLINE_VISIBILITY
@@ -328,7 +329,7 @@ private:
type_info const * __info = nullptr,
const void* __fallback_info = nullptr)
{
- return __h(__a, this, __other, __info, __fallback_info);
+ return __h_(__a, this, __other, __info, __fallback_info);
}
template <class>
@@ -344,8 +345,8 @@ private:
friend add_pointer_t<_ValueType>
any_cast(any *) _NOEXCEPT;
- _HandleFuncPtr __h = nullptr;
- _Storage __s;
+ _HandleFuncPtr __h_ = nullptr;
+ _Storage __s_;
};
namespace __any_imp
@@ -382,9 +383,9 @@ namespace __any_imp
typedef allocator<_Tp> _Alloc;
typedef allocator_traits<_Alloc> _ATraits;
_Alloc __a;
- _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
+ _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s_.__buf));
_ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
- __dest.__h = &_SmallHandler::__handle;
+ __dest.__h_ = &_SmallHandler::__handle;
return *__ret;
}
@@ -394,21 +395,21 @@ namespace __any_imp
typedef allocator<_Tp> _Alloc;
typedef allocator_traits<_Alloc> _ATraits;
_Alloc __a;
- _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
+ _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s_.__buf));
_ATraits::destroy(__a, __p);
- __this.__h = nullptr;
+ __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)));
+ 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))));
+ *static_cast<_Tp*>(static_cast<void*>(&__this.__s_.__buf))));
__destroy(__this);
}
@@ -418,7 +419,7 @@ namespace __any_imp
const void* __fallback_id)
{
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
- return static_cast<void*>(&__this.__s.__buf);
+ return static_cast<void*>(&__this.__s_.__buf);
return nullptr;
}
@@ -470,8 +471,8 @@ namespace __any_imp
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;
+ __dest.__s_.__ptr = __hold.release();
+ __dest.__h_ = &_LargeHandler::__handle;
return *__ret;
}
@@ -482,22 +483,22 @@ namespace __any_imp
typedef allocator<_Tp> _Alloc;
typedef allocator_traits<_Alloc> _ATraits;
_Alloc __a;
- _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
+ _Tp * __p = static_cast<_Tp *>(__this.__s_.__ptr);
_ATraits::destroy(__a, __p);
_ATraits::deallocate(__a, __p, 1);
- __this.__h = nullptr;
+ __this.__h_ = nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void __copy(any const & __this, any & __dest) {
- _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
+ _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;
+ __dest.__s_.__ptr = __this.__s_.__ptr;
+ __dest.__h_ = &_LargeHandler::__handle;
+ __this.__h_ = nullptr;
}
_LIBCPP_INLINE_VISIBILITY
@@ -505,7 +506,7 @@ namespace __any_imp
void const* __fallback_info)
{
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
- return static_cast<void*>(__this.__s.__ptr);
+ return static_cast<void*>(__this.__s_.__ptr);
return nullptr;
}
@@ -525,7 +526,7 @@ namespace __any_imp
template <class _ValueType, class _Tp, class>
-any::any(_ValueType && __v) : __h(nullptr)
+any::any(_ValueType && __v) : __h_(nullptr)
{
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
}
@@ -567,16 +568,16 @@ void any::swap(any & __rhs) _NOEXCEPT
{
if (this == &__rhs)
return;
- if (__h && __rhs.__h) {
+ if (__h_ && __rhs.__h_) {
any __tmp;
__rhs.__call(_Action::_Move, &__tmp);
this->__call(_Action::_Move, &__rhs);
__tmp.__call(_Action::_Move, this);
}
- else if (__h) {
+ else if (__h_) {
this->__call(_Action::_Move, &__rhs);
}
- else if (__rhs.__h) {
+ else if (__rhs.__h_) {
__rhs.__call(_Action::_Move, this);
}
}
@@ -606,7 +607,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any const & __v)
{
- using _RawValueType = __uncvref_t<_ValueType>;
+ using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
"ValueType is required to be a const lvalue reference "
"or a CopyConstructible type");
@@ -621,7 +622,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any & __v)
{
- using _RawValueType = __uncvref_t<_ValueType>;
+ using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
"ValueType is required to be an lvalue reference "
"or a CopyConstructible type");
@@ -636,7 +637,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any && __v)
{
- using _RawValueType = __uncvref_t<_ValueType>;
+ using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType>::value,
"ValueType is required to be an rvalue reference "
"or a CopyConstructible type");
@@ -676,8 +677,8 @@ 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) {
+ typedef add_pointer_t<_ValueType> _ReturnType;
+ if (__any && __any->__h_) {
void *__p = __any->__call(_Action::_Get, nullptr,
#if !defined(_LIBCPP_NO_RTTI)
&typeid(_ValueType),
@@ -695,4 +696,17 @@ any_cast(any * __any) _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+# include <chrono>
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <iosfwd>
+# include <iterator>
+# include <memory>
+# include <variant>
+#endif
+
#endif // _LIBCPP_ANY
diff --git a/libcxx/include/array b/libcxx/include/array
index 867dd6b1bcc6..068a6bd4cc42 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -115,7 +115,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__iterator/reverse_iterator.h>
-#include <__tuple>
+#include <__tuple_dir/sfinae_helpers.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
@@ -123,12 +123,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <iterator>
-# include <utility>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -142,6 +136,10 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <compare>
#include <initializer_list>
+// [tuple.helper]
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -168,42 +166,42 @@ struct _LIBCPP_TEMPLATE_VIS array
_Tp __elems_[_Size];
// No explicit construct/copy/destroy for aggregate type
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void fill(const value_type& __u) {
_VSTD::fill_n(data(), _Size, __u);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
iterator begin() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
iterator end() _NOEXCEPT {return iterator(data() + _Size);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator cbegin() const _NOEXCEPT {return begin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator cend() const _NOEXCEPT {return end();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
// capacity:
@@ -215,39 +213,39 @@ struct _LIBCPP_TEMPLATE_VIS array
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
// element access:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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)
+ _LIBCPP_CONSTEXPR_SINCE_CXX17 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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 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_SINCE_CXX17 reference front() _NOEXCEPT {return (*this)[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT {return (*this)[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
value_type* data() _NOEXCEPT {return __elems_;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const value_type* data() const _NOEXCEPT {return __elems_;}
};
@@ -268,56 +266,55 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
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;
+ typedef __conditional_t<is_const<_Tp>::value, const char, char> _CharType;
struct _ArrayInStructT { _Tp __data_[1]; };
_ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
value_type* data() _NOEXCEPT {return nullptr;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const value_type* data() const _NOEXCEPT {return nullptr;}
// No explicit construct/copy/destroy for aggregate type
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
iterator begin() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
iterator end() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator end() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator cbegin() const _NOEXCEPT {return begin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_iterator cend() const _NOEXCEPT {return end();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
// capacity:
@@ -329,49 +326,49 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
// element access:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
reference at(size_type) {
__throw_out_of_range("array<T, 0>::at");
__libcpp_unreachable();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const_reference at(size_type) const {
__throw_out_of_range("array<T, 0>::at");
__libcpp_unreachable();
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const_reference back() const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
__libcpp_unreachable();
@@ -389,7 +386,7 @@ array(_Tp, _Args...)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
@@ -397,7 +394,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return !(__x == __y);
@@ -405,7 +402,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
@@ -414,7 +411,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return __y < __x;
@@ -422,7 +419,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return !(__y < __x);
@@ -430,14 +427,14 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
template <class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 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
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
_NOEXCEPT_(noexcept(__x.swap(__y)))
@@ -457,7 +454,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
};
template <size_t _Ip, class _Tp, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp&
get(array<_Tp, _Size>& __a) _NOEXCEPT
{
@@ -466,7 +463,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT
}
template <size_t _Ip, class _Tp, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
get(const array<_Tp, _Size>& __a) _NOEXCEPT
{
@@ -475,7 +472,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT
}
template <size_t _Ip, class _Tp, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp&&
get(array<_Tp, _Size>&& __a) _NOEXCEPT
{
@@ -484,7 +481,7 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT
}
template <size_t _Ip, class _Tp, size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&&
get(const array<_Tp, _Size>&& __a) _NOEXCEPT
{
@@ -535,4 +532,11 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <concepts>
+# include <iterator>
+# include <utility>
+#endif
+
#endif // _LIBCPP_ARRAY
diff --git a/libcxx/include/atomic b/libcxx/include/atomic
index 92da4820e928..d0d682da6238 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -377,23 +377,23 @@ template<class T>
memory_order) noexcept;
template<class T>
- void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type);
+ void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept;
template<class T>
- void atomic_wait(const atomic<T>*, atomic<T>::value_type);
+ void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept;
template<class T>
void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,
- memory_order);
+ memory_order) noexcept;
template<class T>
void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,
- memory_order);
+ memory_order) noexcept;
template<class T>
- void atomic_notify_one(volatile atomic<T>*);
+ void atomic_notify_one(volatile atomic<T>*) noexcept;
template<class T>
- void atomic_notify_one(atomic<T>*);
+ void atomic_notify_one(atomic<T>*) noexcept;
template<class T>
- void atomic_notify_all(volatile atomic<T>*);
+ void atomic_notify_all(volatile atomic<T>*) noexcept;
template<class T>
- void atomic_notify_all(atomic<T>*);
+ void atomic_notify_all(atomic<T>*) noexcept;
// Atomics for standard typedef types
@@ -524,20 +524,25 @@ template <class T>
#include <__config>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_trivially_copyable.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_pointer.h>
+#include <__type_traits/underlying_type.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
-#include <type_traits>
#include <version>
#ifndef _LIBCPP_HAS_NO_THREADS
# include <__threading_support>
#endif
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -948,13 +953,13 @@ void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_ord
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*;
+ using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
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*;
+ using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
}
@@ -1113,6 +1118,12 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
# define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#endif
+template <class _Tp>
+struct __libcpp_is_always_lock_free {
+ // __atomic_always_lock_free is available in all Standard modes
+ static const bool __value = __atomic_always_lock_free(sizeof(_Tp), 0);
+};
+
#ifdef _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
template<typename _Tp>
@@ -1404,42 +1415,8 @@ _Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a,
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,
+ typename _Base = typename conditional<__libcpp_is_always_lock_free<_Tp>::__value,
__cxx_atomic_base_impl<_Tp>,
__cxx_atomic_lock_impl<_Tp> >::type>
#else
@@ -1463,17 +1440,7 @@ struct __cxx_atomic_impl : public _Base {
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
+#ifndef _LIBCPP_HAS_NO_THREADS
_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*);
@@ -1494,10 +1461,10 @@ struct __libcpp_atomic_wait_backoff_impl {
{
if(__elapsed > chrono::microseconds(64))
{
- auto const __monitor = __libcpp_atomic_monitor(__a);
+ auto const __monitor = std::__libcpp_atomic_monitor(__a);
if(__test_fn())
return true;
- __libcpp_atomic_wait(__a, __monitor);
+ std::__libcpp_atomic_wait(__a, __monitor);
}
else if(__elapsed > chrono::microseconds(4))
__libcpp_thread_yield();
@@ -1512,10 +1479,10 @@ _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);
+ return std::__libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
}
-#else // _LIBCPP_HAS_NO_PLATFORM_WAIT
+#else // _LIBCPP_HAS_NO_THREADS
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }
@@ -1524,15 +1491,10 @@ _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> co
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());
+ return __libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy());
}
-#endif // _LIBCPP_HAS_NO_PLATFORM_WAIT
+#endif // _LIBCPP_HAS_NO_THREADS
template <class _Atp, class _Tp>
struct __cxx_atomic_wait_test_fn_impl {
@@ -1541,7 +1503,7 @@ struct __cxx_atomic_wait_test_fn_impl {
memory_order __order;
_LIBCPP_INLINE_VISIBILITY bool operator()() const
{
- return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val);
+ return !std::__cxx_nonatomic_compare_equal(std::__cxx_atomic_load(__a, __order), __val);
}
};
@@ -1550,7 +1512,7 @@ _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);
+ return std::__cxx_atomic_wait(__a, __test_fn);
}
// general atomic<T>
@@ -1561,7 +1523,7 @@ 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);
+ static _LIBCPP_CONSTEXPR bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -1573,78 +1535,78 @@ struct __atomic_base // false
_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);}
+ {std::__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);}
+ {std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {std::__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);}
+ {std::__cxx_atomic_wait(&__a_, __v, __m);}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
- {__cxx_atomic_notify_one(&__a_);}
+ {std::__cxx_atomic_notify_one(&__a_);}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
- {__cxx_atomic_notify_one(&__a_);}
+ {std::__cxx_atomic_notify_one(&__a_);}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
- {__cxx_atomic_notify_all(&__a_);}
+ {std::__cxx_atomic_notify_all(&__a_);}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
- {__cxx_atomic_notify_all(&__a_);}
+ {std::__cxx_atomic_notify_all(&__a_);}
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY constexpr
@@ -1673,7 +1635,7 @@ struct __atomic_base<_Tp, true>
{
typedef __atomic_base<_Tp, false> __base;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__atomic_base() _NOEXCEPT = default;
_LIBCPP_INLINE_VISIBILITY
@@ -1681,34 +1643,34 @@ struct __atomic_base<_Tp, true>
_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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__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);}
+ {return std::__cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
@@ -1806,29 +1768,29 @@ struct atomic<_Tp*>
_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);
+ static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
+ return std::__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);
+ static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
+ return std::__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);
+ static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
+ return std::__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);
+ static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
+ return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);
}
_LIBCPP_INLINE_VISIBILITY
@@ -1885,7 +1847,7 @@ _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);
+ std::__cxx_atomic_init(&__o->__a_, __d);
}
template <class _Tp>
@@ -1893,7 +1855,7 @@ _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);
+ std::__cxx_atomic_init(&__o->__a_, __d);
}
// atomic_store
@@ -2146,7 +2108,7 @@ void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
__o->notify_one();
}
-// atomic_notify_one
+// atomic_notify_all
template <class _Tp>
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
@@ -2664,23 +2626,23 @@ 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)
+# define _LIBCPP_CONTENTION_LOCK_FREE ::std::__libcpp_is_always_lock_free<__cxx_contention_t>::__value
#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;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long> __libcpp_signed_lock_free;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long> __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;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int> __libcpp_signed_lock_free;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int> __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;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short> __libcpp_signed_lock_free;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short> __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;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char> __libcpp_signed_lock_free;
+typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char> __libcpp_unsigned_lock_free;
#else
// No signed/unsigned lock-free types
#define _LIBCPP_NO_LOCK_FREE_TYPES
@@ -2702,4 +2664,10 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <cmath>
+# include <compare>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_ATOMIC
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 00518035283f..2e8906b71379 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -48,10 +48,11 @@ namespace std
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
+#include <__memory/unique_ptr.h>
#include <__thread/timed_backoff_policy.h>
+#include <__utility/move.h>
#include <atomic>
#include <limits>
-#include <memory>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -124,7 +125,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
__barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
- : __expected_(__expected), __base_(__construct_barrier_algorithm_base(this->__expected_),
+ : __expected_(__expected), __base_(std::__construct_barrier_algorithm_base(this->__expected_),
&__destroy_barrier_algorithm_base),
__expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)
{
@@ -149,7 +150,7 @@ public:
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());
+ std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
@@ -283,7 +284,7 @@ public:
template<class _CompletionF = __empty_completion>
class barrier {
- __barrier_base<_CompletionF> __b;
+ __barrier_base<_CompletionF> __b_;
public:
using arrival_token = typename __barrier_base<_CompletionF>::arrival_token;
@@ -293,7 +294,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
- : __b(__count, _VSTD::move(__completion)) {
+ : __b_(__count, _VSTD::move(__completion)) {
}
barrier(barrier const&) = delete;
@@ -302,12 +303,12 @@ public:
[[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
arrival_token arrive(ptrdiff_t __update = 1)
{
- return __b.arrive(__update);
+ return __b_.arrive(__update);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __phase) const
{
- __b.wait(_VSTD::move(__phase));
+ __b_.wait(_VSTD::move(__phase));
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait()
@@ -317,7 +318,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
- __b.arrive_and_drop();
+ __b_.arrive_and_drop();
}
};
@@ -327,4 +328,12 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <iterator>
+# include <memory>
+# include <stdexcept>
+# include <variant>
+#endif
+
#endif //_LIBCPP_BARRIER
diff --git a/libcxx/include/bit b/libcxx/include/bit
index 15bc13a504b1..d17a6e45f0db 100644
--- a/libcxx/include/bit
+++ b/libcxx/include/bit
@@ -63,197 +63,29 @@ namespace std {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit/bit_cast.h>
+#include <__bit/bit_ceil.h>
+#include <__bit/bit_floor.h>
+#include <__bit/bit_log2.h>
+#include <__bit/bit_width.h>
+#include <__bit/blsr.h>
#include <__bit/byteswap.h>
-#include <__bits> // __libcpp_clz
-#include <__concepts/arithmetic.h>
+#include <__bit/countl.h>
+#include <__bit/countr.h>
+#include <__bit/endian.h>
+#include <__bit/has_single_bit.h>
+#include <__bit/popcount.h>
+#include <__bit/rotate.h>
#include <__config>
-#include <limits>
-#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iosfwd>
-#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_HIDE_FROM_ABI _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_HIDE_FROM_ABI _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 std::__libcpp_clz(static_cast<unsigned int>(__t))
- - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
- else if (sizeof(_Tp) <= sizeof(unsigned long))
- return std::__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 std::__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 = std::__rotr(__t, __ulldigits);
- if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
- break;
- __ret += __iter;
- }
- return __ret + __iter;
- }
-}
-
-#if _LIBCPP_STD_VER > 17
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
- const unsigned int __dig = numeric_limits<_Tp>::digits;
- if ((__cnt % __dig) == 0)
- return __t;
- return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
- return std::__rotr(__t, __cnt);
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
- return std::__countl_zero(__t);
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
- return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
- if (__t == 0)
- return numeric_limits<_Tp>::digits;
-
- if (sizeof(_Tp) <= sizeof(unsigned int))
- return std::__libcpp_ctz(static_cast<unsigned int>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long))
- return std::__libcpp_ctz(static_cast<unsigned long>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long long))
- return std::__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 + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
- }
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
- return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
- if (sizeof(_Tp) <= sizeof(unsigned int))
- return std::__libcpp_popcount(static_cast<unsigned int>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long))
- return std::__libcpp_popcount(static_cast<unsigned long>(__t));
- else if (sizeof(_Tp) <= sizeof(unsigned long long))
- return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
- else {
- int __ret = 0;
- while (__t != 0) {
- __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
- __t >>= numeric_limits<unsigned long long>::digits;
- }
- return __ret;
- }
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
- return __t != 0 && (((__t & (__t - 1)) == 0));
-}
-
-// integral log base 2
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
- return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
- return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
-}
-
-template <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
- if (__t < 2)
- return 1;
- const unsigned __n = numeric_limits<_Tp>::digits - std::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 <__libcpp_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
- return __t == 0 ? 0 : std::__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
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
+# include <limits>
+# include <type_traits>
+#endif
#endif // _LIBCPP_BIT
diff --git a/libcxx/include/bitset b/libcxx/include/bitset
index 0f997cef8316..c260f9f592c0 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -42,61 +42,61 @@ public:
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'));
+ charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
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'));
+ charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
// 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);
+ bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23
+ bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23
+ bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23
+ bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23
+ bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23
+ bitset& set() noexcept; // constexpr since C++23
+ bitset& set(size_t pos, bool val = true); // constexpr since C++23
+ bitset& reset() noexcept; // constexpr since C++23
+ bitset& reset(size_t pos); // constexpr since C++23
+ bitset operator~() const noexcept; // constexpr since C++23
+ bitset& flip() noexcept; // constexpr since C++23
+ bitset& flip(size_t pos); // constexpr since C++23
// 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>
+ constexpr bool operator[](size_t pos) const;
+ reference operator[](size_t pos); // constexpr since C++23
+ unsigned long to_ulong() const; // constexpr since C++23
+ unsigned long long to_ullong() const; // constexpr since C++23
+ template <class charT, class traits, class Allocator> // constexpr since C++23
basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
- template <class charT, class traits>
+ template <class charT, class traits> // constexpr since C++23
basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
- template <class charT>
+ template <class charT> // constexpr since C++23
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;
+ basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; // constexpr since C++23
+ size_t count() const noexcept; // constexpr since C++23
+ constexpr size_t size() const noexcept; // constexpr since C++23
+ bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23
+ bool operator!=(const bitset& rhs) const noexcept; // constexpr since C++23
+ bool test(size_t pos) const; // constexpr since C++23
+ bool all() const noexcept; // constexpr since C++23
+ bool any() const noexcept; // constexpr since C++23
+ bool none() const noexcept; // constexpr since C++23
+ bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23
+ bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23
};
// 23.3.5.3 bitset operators:
template <size_t N>
-bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
+bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
template <size_t N>
-bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
+bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
template <size_t N>
-bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
+bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
template <class charT, class traits, size_t N>
basic_istream<charT, traits>&
@@ -118,12 +118,15 @@ template <size_t N> struct hash<std::bitset<N>>;
#include <__config>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
+#include <__type_traits/is_char_like_type.h>
#include <climits>
#include <cstddef>
#include <stdexcept>
#include <version>
// standard-mandated includes
+
+// [bitset.syn]
#include <iosfwd>
#include <string>
@@ -177,30 +180,30 @@ protected:
_LIBCPP_INLINE_VISIBILITY
explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
{return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator&=(const __bitset& __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator|=(const __bitset& __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator^=(const __bitset& __v) _NOEXCEPT;
- void flip() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_t __hash_code() const _NOEXCEPT;
private:
@@ -209,14 +212,17 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __init(unsigned long long __v, true_type) _NOEXCEPT;
#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long to_ulong(false_type) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long to_ulong(true_type) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong(false_type) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong(true_type) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong(true_type, false_type) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong(true_type, true_type) const;
};
@@ -289,7 +295,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
template <size_t _N_words, size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
{
for (size_type __i = 0; __i < _N_words; ++__i)
@@ -298,7 +304,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
template <size_t _N_words, size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
{
for (size_type __i = 0; __i < _N_words; ++__i)
@@ -307,7 +313,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
template <size_t _N_words, size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
{
for (size_type __i = 0; __i < _N_words; ++__i)
@@ -315,7 +321,7 @@ __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
}
template <size_t _N_words, size_t _Size>
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<_N_words, _Size>::flip() _NOEXCEPT
{
// do middle whole words
@@ -334,7 +340,7 @@ __bitset<_N_words, _Size>::flip() _NOEXCEPT
}
template <size_t _N_words, size_t _Size>
-unsigned long
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
__bitset<_N_words, _Size>::to_ulong(false_type) const
{
const_iterator __e = __make_iter(_Size);
@@ -347,14 +353,14 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
template <size_t _N_words, size_t _Size>
inline
-unsigned long
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
__bitset<_N_words, _Size>::to_ullong(false_type) const
{
const_iterator __e = __make_iter(_Size);
@@ -367,7 +373,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
template <size_t _N_words, size_t _Size>
inline
-unsigned long long
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 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)>());
@@ -375,14 +381,14 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const
template <size_t _N_words, size_t _Size>
inline
-unsigned long long
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
{
unsigned long long __r = __first_[0];
@@ -392,7 +398,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
}
template <size_t _N_words, size_t _Size>
-bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
__bitset<_N_words, _Size>::all() const _NOEXCEPT
{
// do middle whole words
@@ -412,7 +418,7 @@ __bitset<_N_words, _Size>::all() const _NOEXCEPT
}
template <size_t _N_words, size_t _Size>
-bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
__bitset<_N_words, _Size>::any() const _NOEXCEPT
{
// do middle whole words
@@ -473,33 +479,33 @@ protected:
_LIBCPP_INLINE_VISIBILITY
explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
{return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator&=(const __bitset& __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator|=(const __bitset& __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void operator^=(const __bitset& __v) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
void flip() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long to_ulong() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool all() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool any() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
@@ -527,7 +533,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
template <size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
{
__first_ &= __v.__first_;
@@ -535,7 +541,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
template <size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
{
__first_ |= __v.__first_;
@@ -543,7 +549,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
template <size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
{
__first_ ^= __v.__first_;
@@ -551,7 +557,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
template <size_t _Size>
inline
-void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
__bitset<1, _Size>::flip() _NOEXCEPT
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
@@ -561,7 +567,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT
template <size_t _Size>
inline
-unsigned long
+_LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
__bitset<1, _Size>::to_ulong() const
{
return __first_;
@@ -569,7 +575,7 @@ __bitset<1, _Size>::to_ulong() const
template <size_t _Size>
inline
-unsigned long long
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
__bitset<1, _Size>::to_ullong() const
{
return __first_;
@@ -577,7 +583,7 @@ __bitset<1, _Size>::to_ullong() const
template <size_t _Size>
inline
-bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
__bitset<1, _Size>::all() const _NOEXCEPT
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
@@ -586,7 +592,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT
template <size_t _Size>
inline
-bool
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
__bitset<1, _Size>::any() const _NOEXCEPT
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
@@ -630,26 +636,26 @@ protected:
_LIBCPP_INLINE_VISIBILITY
explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT
{return iterator(nullptr, 0);}
- _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {return 0;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 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 _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT {return true;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {return false;}
_LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
};
@@ -686,10 +692,12 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
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>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
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 =
@@ -697,24 +705,29 @@ public:
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
// 23.3.5.2 bitset operations:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& operator<<=(size_t __pos) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& operator>>=(size_t __pos) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& set() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& set(size_t __pos, bool __val = true);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& reset() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& reset(size_t __pos);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset operator~() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& flip() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset& flip(size_t __pos);
// element access:
@@ -723,41 +736,43 @@ public:
#else
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
#endif
- _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long to_ulong() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long to_ullong() const;
template <class _CharT, class _Traits, class _Allocator>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1')) const;
template <class _CharT, class _Traits>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1')) const;
template <class _CharT>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
_CharT __one = _CharT('1')) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
char __one = '1') const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
size_t count() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool operator==(const bitset& __rhs) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool operator!=(const bitset& __rhs) const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool test(size_t __pos) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool all() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bool any() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT {return !any();}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset operator<<(size_t __pos) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset operator>>(size_t __pos) const _NOEXCEPT;
private:
@@ -770,6 +785,7 @@ private:
template <size_t _Size>
template<class _CharT, class>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>::bitset(const _CharT* __str,
typename basic_string<_CharT>::size_type __n,
_CharT __zero, _CharT __one)
@@ -791,6 +807,7 @@ bitset<_Size>::bitset(const _CharT* __str,
template <size_t _Size>
template<class _CharT, class _Traits, class _Allocator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
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,
@@ -816,6 +833,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
{
@@ -825,6 +843,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
{
@@ -834,6 +853,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
{
@@ -842,6 +862,7 @@ bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
{
@@ -852,6 +873,7 @@ bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
{
@@ -863,6 +885,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::set() _NOEXCEPT
{
@@ -871,6 +894,7 @@ bitset<_Size>::set() _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::set(size_t __pos, bool __val)
{
@@ -883,6 +907,7 @@ bitset<_Size>::set(size_t __pos, bool __val)
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::reset() _NOEXCEPT
{
@@ -891,6 +916,7 @@ bitset<_Size>::reset() _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::reset(size_t __pos)
{
@@ -903,6 +929,7 @@ bitset<_Size>::reset(size_t __pos)
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
bitset<_Size>::operator~() const _NOEXCEPT
{
@@ -913,6 +940,7 @@ bitset<_Size>::operator~() const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::flip() _NOEXCEPT
{
@@ -921,6 +949,7 @@ bitset<_Size>::flip() _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>&
bitset<_Size>::flip(size_t __pos)
{
@@ -934,6 +963,7 @@ bitset<_Size>::flip(size_t __pos)
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long
bitset<_Size>::to_ulong() const
{
@@ -942,6 +972,7 @@ bitset<_Size>::to_ulong() const
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
unsigned long long
bitset<_Size>::to_ullong() const
{
@@ -950,6 +981,7 @@ bitset<_Size>::to_ullong() const
template <size_t _Size>
template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, _Traits, _Allocator>
bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
{
@@ -965,6 +997,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
template <size_t _Size>
template <class _CharT, class _Traits>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, _Traits, allocator<_CharT> >
bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
{
@@ -974,6 +1007,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
template <size_t _Size>
template <class _CharT>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
{
@@ -982,6 +1016,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
basic_string<char, char_traits<char>, allocator<char> >
bitset<_Size>::to_string(char __zero, char __one) const
{
@@ -990,6 +1025,7 @@ bitset<_Size>::to_string(char __zero, char __one) const
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
size_t
bitset<_Size>::count() const _NOEXCEPT
{
@@ -998,6 +1034,7 @@ bitset<_Size>::count() const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool
bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
{
@@ -1006,6 +1043,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool
bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
{
@@ -1013,6 +1051,7 @@ bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
}
template <size_t _Size>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool
bitset<_Size>::test(size_t __pos) const
{
@@ -1024,6 +1063,7 @@ bitset<_Size>::test(size_t __pos) const
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool
bitset<_Size>::all() const _NOEXCEPT
{
@@ -1032,6 +1072,7 @@ bitset<_Size>::all() const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bool
bitset<_Size>::any() const _NOEXCEPT
{
@@ -1040,6 +1081,7 @@ bitset<_Size>::any() const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
{
@@ -1050,6 +1092,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
template <size_t _Size>
inline
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
{
@@ -1059,7 +1102,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
}
template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
{
@@ -1069,7 +1112,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
}
template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
{
@@ -1079,7 +1122,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
}
template <size_t _Size>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
bitset<_Size>
operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
{
@@ -1098,15 +1141,19 @@ struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
};
template <class _CharT, class _Traits, size_t _Size>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+#endif
+
#endif // _LIBCPP_BITSET
diff --git a/libcxx/include/cassert b/libcxx/include/cassert
index 28fc0b10e9f4..761f57dee1db 100644
--- a/libcxx/include/cassert
+++ b/libcxx/include/cassert
@@ -18,7 +18,14 @@ Macros:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <assert.h>
+
+// <assert.h> is not provided by libc++
+#if __has_include(<assert.h>)
+# include <assert.h>
+# ifdef _LIBCPP_ASSERT_H
+# error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/cctype b/libcxx/include/cctype
index 248f8d98000f..867e7d5b0b35 100644
--- a/libcxx/include/cctype
+++ b/libcxx/include/cctype
@@ -36,8 +36,16 @@ int toupper(int c);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <ctype.h>
+#ifndef _LIBCPP_CTYPE_H
+# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cerrno b/libcxx/include/cerrno
index e9eacd35effe..937ec23c6971 100644
--- a/libcxx/include/cerrno
+++ b/libcxx/include/cerrno
@@ -24,8 +24,17 @@ Macros:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <errno.h>
+#ifndef _LIBCPP_ERRNO_H
+# error <cerrno> tried including <errno.h> but didn't find libc++'s <errno.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cfenv b/libcxx/include/cfenv
index e42b46680d15..16b3761ee27b 100644
--- a/libcxx/include/cfenv
+++ b/libcxx/include/cfenv
@@ -54,8 +54,17 @@ int feupdateenv(const fenv_t* envp);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <fenv.h>
+#ifndef _LIBCPP_FENV_H
+# error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cfloat b/libcxx/include/cfloat
index 36a7c51cdda5..4f991dd49ff4 100644
--- a/libcxx/include/cfloat
+++ b/libcxx/include/cfloat
@@ -71,8 +71,17 @@ Macros:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <float.h>
+#ifndef _LIBCPP_FLOAT_H
+# error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/charconv b/libcxx/include/charconv
index 4f00755a83bb..9c74ce3c697f 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -30,8 +30,8 @@ namespace std {
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);
+ constexpr to_chars_result to_chars(char* first, char* last, see below value,
+ int base = 10); // constexpr since C++23
to_chars_result to_chars(char* first, char* last, bool value,
int base = 10) = delete;
@@ -60,8 +60,8 @@ namespace std {
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);
+ constexpr from_chars_result from_chars(const char* first, const char* last,
+ see below& value, int base = 10); // constexpr since C++23
from_chars_result from_chars(const char* first, const char* last,
float& value,
@@ -77,9 +77,10 @@ namespace std {
*/
+#include <__algorithm/copy_n.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
-#include <__bits>
+#include <__bit/countl.h>
#include <__charconv/chars_format.h>
#include <__charconv/from_chars_result.h>
#include <__charconv/tables.h>
@@ -88,6 +89,7 @@ namespace std {
#include <__config>
#include <__debug>
#include <__errc>
+#include <__memory/addressof.h>
#include <__type_traits/make_32_64_or_128_bit.h>
#include <__utility/unreachable.h>
#include <cmath> // for log2f
@@ -97,10 +99,6 @@ namespace std {
#include <limits>
#include <type_traits>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iosfwd>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -110,7 +108,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
@@ -134,18 +132,18 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
/// function requires its input to have at least one bit set the value of
/// zero is set to one. This means the first element of the lookup table is
/// zero.
- static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
{
auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
- return __t - (__v < __table<>::__pow10_32[__t]) + 1;
+ return __t - (__v < __itoa::__pow10_32[__t]) + 1;
}
- static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
{
return __itoa::__base_10_u32(__p, __v);
}
- static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_32)& __pow() { return __itoa::__pow10_32; }
};
template <typename _Tp>
@@ -161,14 +159,14 @@ struct _LIBCPP_HIDDEN
/// function requires its input to have at least one bit set the value of
/// zero is set to one. This means the first element of the lookup table is
/// zero.
- static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
- return __t - (__v < __table<>::__pow10_64[__t]) + 1;
+ return __t - (__v < __itoa::__pow10_64[__t]) + 1;
}
- static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
- static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_64)& __pow() { return __itoa::__pow10_64; }
};
@@ -186,25 +184,25 @@ struct _LIBCPP_HIDDEN
/// function requires its input to have at least one bit set the value of
/// zero is set to one. This means the first element of the lookup table is
/// zero.
- static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
_LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
// There's always a bit set in the upper 64-bits.
auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
- _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds");
+ _LIBCPP_ASSERT(__t >= __itoa::__pow10_128_offset, "Index out of bounds");
// __t is adjusted since the lookup table misses the lower entries.
- return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1;
+ return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1;
}
- static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
// TODO FMT This pow function should get an index.
// By moving this to its own header it can be reused by the pow function in to_chars_base_10.
- static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_128)& __pow() { return __itoa::__pow10_128; }
};
#endif
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
{
auto __c = __a * __b;
@@ -213,7 +211,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
{
auto __c = __a * __b;
@@ -222,24 +220,18 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI bool
-__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
+_LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
{
- return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
+ return __itoa::__mul_overflowed(__a, static_cast<_Tp>(__b), __r);
}
template <typename _Tp>
@@ -250,7 +242,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
using typename __traits_base<_Tp>::type;
// precondition: at least one non-zero character available
- static _LIBCPP_HIDE_FROM_ABI char const*
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char const*
__read(char const* __p, char const* __ep, type& __a, type& __b)
{
type __cprod[digits];
@@ -258,20 +250,20 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
int __i = digits;
do
{
- if (!('0' <= *__p && *__p <= '9'))
+ if (*__p < '0' || *__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))
+ if (__itoa::__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
--__p;
return __p;
}
template <typename _It1, typename _It2, class _Up>
- static _LIBCPP_HIDE_FROM_ABI _Up
+ static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Up
__inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
{
for (; __first1 < __last1; ++__first1, ++__first2)
@@ -283,7 +275,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
} // namespace __itoa
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI _Tp
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp
__complement(_Tp __x)
{
static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
@@ -291,21 +283,25 @@ __complement(_Tp __x)
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
+__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type);
+
+template <typename _Tp>
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
{
- auto __x = __to_unsigned_like(__value);
+ auto __x = std::__to_unsigned_like(__value);
if (__value < 0 && __first != __last)
{
*__first++ = '-';
- __x = __complement(__x);
+ __x = std::__complement(__x);
}
- return __to_chars_itoa(__first, __last, __x, false_type());
+ return std::__to_chars_itoa(__first, __last, __x, false_type());
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
{
using __tx = __itoa::__traits<_Tp>;
@@ -319,7 +315,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
# ifndef _LIBCPP_HAS_NO_INT128
template <>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
{
// When the value fits in 64-bits use the 64-bit code path. This reduces
@@ -339,19 +335,23 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
}
#endif
+template <class _Tp>
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
+__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type);
+
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
true_type)
{
- auto __x = __to_unsigned_like(__value);
+ auto __x = std::__to_unsigned_like(__value);
if (__value < 0 && __first != __last)
{
*__first++ = '-';
- __x = __complement(__x);
+ __x = std::__complement(__x);
}
- return __to_chars_integral(__first, __last, __x, __base, false_type());
+ return std::__to_chars_integral(__first, __last, __x, __base, false_type());
}
namespace __itoa {
@@ -370,7 +370,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
}
template <typename _Tp>
- _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
ptrdiff_t __cap = __last - __first;
int __n = __width(__value);
if (__n > __cap)
@@ -383,7 +383,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
unsigned __c = __value % __divisor;
__value /= __divisor;
__p -= 4;
- std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4);
+ std::copy_n(&__base_2_lut[4 * __c], 4, __p);
}
do {
unsigned __c = __value % 2;
@@ -405,7 +405,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
}
template <typename _Tp>
- _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
ptrdiff_t __cap = __last - __first;
int __n = __width(__value);
if (__n > __cap)
@@ -418,7 +418,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
unsigned __c = __value % __divisor;
__value /= __divisor;
__p -= 2;
- std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2);
+ std::copy_n(&__base_8_lut[2 * __c], 2, __p);
}
do {
unsigned __c = __value % 8;
@@ -441,7 +441,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
}
template <typename _Tp>
- _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
ptrdiff_t __cap = __last - __first;
int __n = __width(__value);
if (__n > __cap)
@@ -454,7 +454,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
unsigned __c = __value % __divisor;
__value /= __divisor;
__p -= 2;
- std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2);
+ std::copy_n(&__base_16_lut[2 * __c], 2, __p);
}
if (__first != __last)
do {
@@ -470,34 +470,34 @@ struct _LIBCPP_HIDDEN __integral<16> {
template <unsigned _Base, typename _Tp,
typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
-_LIBCPP_HIDE_FROM_ABI int
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
__to_chars_integral_width(_Tp __value) {
return __itoa::__integral<_Base>::__width(__value);
}
template <unsigned _Base, typename _Tp,
typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
-_LIBCPP_HIDE_FROM_ABI int
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
__to_chars_integral_width(_Tp __value) {
return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
}
template <unsigned _Base, typename _Tp,
typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
-_LIBCPP_HIDE_FROM_ABI to_chars_result
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value) {
return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
}
template <unsigned _Base, typename _Tp,
typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
-_LIBCPP_HIDE_FROM_ABI to_chars_result
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value) {
return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
}
template <typename _Tp>
-_LIBCPP_HIDE_FROM_ABI int
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
__to_chars_integral_width(_Tp __value, unsigned __base) {
_LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
@@ -524,24 +524,24 @@ __to_chars_integral_width(_Tp __value, unsigned __base) {
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
false_type)
{
if (__base == 10) [[likely]]
- return __to_chars_itoa(__first, __last, __value, false_type());
+ return std::__to_chars_itoa(__first, __last, __value, false_type());
switch (__base) {
case 2:
- return __to_chars_integral<2>(__first, __last, __value);
+ return std::__to_chars_integral<2>(__first, __last, __value);
case 8:
- return __to_chars_integral<8>(__first, __last, __value);
+ return std::__to_chars_integral<8>(__first, __last, __value);
case 16:
- return __to_chars_integral<16>(__first, __last, __value);
+ return std::__to_chars_integral<16>(__first, __last, __value);
}
ptrdiff_t __cap = __last - __first;
- int __n = __to_chars_integral_width(__value, __base);
+ int __n = std::__to_chars_integral_width(__value, __base);
if (__n > __cap)
return {__last, errc::value_too_large};
@@ -556,7 +556,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
to_chars(char* __first, char* __last, _Tp __value)
{
using _Type = __make_32_64_or_128_bit_t<_Tp>;
@@ -565,7 +565,7 @@ to_chars(char* __first, char* __last, _Tp __value)
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI to_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
to_chars(char* __first, char* __last, _Tp __value, int __base)
{
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
@@ -575,11 +575,11 @@ to_chars(char* __first, char* __last, _Tp __value, int __base)
}
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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;
+ decltype(std::__to_unsigned_like(__value)) __x;
bool __neg = (__first != __last && *__first == '-');
auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
@@ -595,16 +595,16 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
if (__neg)
{
- if (__x <= __complement(__to_unsigned_like(__tl::min())))
+ if (__x <= std::__complement(std::__to_unsigned_like(__tl::min())))
{
- __x = __complement(__x);
- std::memcpy(&__value, &__x, sizeof(__x));
+ __x = std::__complement(__x);
+ std::copy_n(std::addressof(__x), 1, std::addressof(__value));
return __r;
}
}
else
{
- if (__x <= __to_unsigned_like(__tl::max()))
+ if (__x <= std::__to_unsigned_like(__tl::max()))
{
__value = __x;
return __r;
@@ -615,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
}
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
__in_pattern(_Tp __c)
{
return '0' <= __c && __c <= '9';
@@ -626,16 +626,16 @@ struct _LIBCPP_HIDDEN __in_pattern_result
bool __ok;
int __val;
- explicit _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
+ explicit _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
};
template <typename _Tp>
-inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __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))
+ else if (std::__in_pattern(__c))
return {true, __c - '0'};
else if ('a' <= __c && __c < 'a' + __base - 10)
return {true, __c - 'a' + 10};
@@ -644,7 +644,7 @@ __in_pattern(_Tp __c, int __base)
}
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
_Ts... __args)
{
@@ -656,7 +656,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
};
auto __p = __find_non_zero(__first, __last);
- if (__p == __last || !__in_pattern(*__p, __args...))
+ if (__p == __last || !std::__in_pattern(*__p, __args...))
{
if (__p == __first)
return {__first, errc::invalid_argument};
@@ -672,7 +672,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
{
for (; __r.ptr != __last; ++__r.ptr)
{
- if (!__in_pattern(*__r.ptr, __args...))
+ if (!std::__in_pattern(*__r.ptr, __args...))
break;
}
}
@@ -681,19 +681,19 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
}
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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(
+ return std::__subject_seq_combinator(
__first, __last, __value,
[](const char* __f, const char* __l,
_Tp& __val) -> from_chars_result {
__output_type __a, __b;
auto __p = __tx::__read(__f, __l, __a, __b);
- if (__p == __l || !__in_pattern(*__p))
+ if (__p == __l || !std::__in_pattern(*__p))
{
__output_type __m = numeric_limits<_Tp>::max();
if (__m >= __a && __m - __a >= __b)
@@ -707,27 +707,47 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
}
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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>);
+ using __t = decltype(std::__to_unsigned_like(__value));
+ return std::__sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
+}
+
+
+/*
+// Code used to generate __from_chars_log2f_lut.
+#include <cmath>
+#include <iostream>
+#include <format>
+
+int main() {
+ for (int i = 2; i <= 36; ++i)
+ std::cout << std::format("{},\n", log2f(i));
}
+*/
+/// log2f table for bases [2, 36].
+inline constexpr float __from_chars_log2f_lut[35] = {
+ 1, 1.5849625, 2, 2.321928, 2.5849626, 2.807355, 3, 3.169925, 3.321928,
+ 3.4594316, 3.5849626, 3.7004397, 3.807355, 3.9068906, 4, 4.087463, 4.169925, 4.2479277,
+ 4.321928, 4.3923173, 4.4594316, 4.523562, 4.5849624, 4.643856, 4.70044, 4.7548876, 4.807355,
+ 4.857981, 4.9068904, 4.9541965, 5, 5.044394, 5.087463, 5.129283, 5.169925};
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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 std::__from_chars_atoi(__first, __last, __value);
- return __subject_seq_combinator(
+ return std::__subject_seq_combinator(
__first, __last, __value,
[](const char* __p, const char* __lastp, _Tp& __val,
int __b) -> from_chars_result {
using __tl = numeric_limits<_Tp>;
- auto __digits = __tl::digits / log2f(float(__b));
+ // __base is always between 2 and 36 inclusive.
+ auto __digits = __tl::digits / __from_chars_log2f_lut[__b - 2];
_Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;
for (int __i = 1; __p != __lastp; ++__i, ++__p)
@@ -762,34 +782,30 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
}
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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);
+ using __t = decltype(std::__to_unsigned_like(__value));
+ return std::__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_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
from_chars(const char* __first, const char* __last, _Tp& __value)
{
- return __from_chars_atoi(__first, __last, __value);
+ return std::__from_chars_atoi(__first, __last, __value);
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-inline _LIBCPP_HIDE_FROM_ABI from_chars_result
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI 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);
+ return std::__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);
@@ -817,11 +833,15 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form
_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
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <iosfwd>
+#endif
+
#endif // _LIBCPP_CHARCONV
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 2af5fbcc5165..44073b557ba1 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -207,7 +207,11 @@ template <class ToDuration, class Rep, class Period>
template <class ToDuration, class Rep, class Period>
constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
-// duration I/O is elsewhere
+// duration I/O
+template<class charT, class traits, class Rep, class Period> // C++20
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const duration<Rep, Period>& d);
// time_point arithmetic (all constexpr in C++14)
template <class Clock, class Duration1, class Rep2, class Period2>
@@ -332,32 +336,35 @@ 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const day& d);
// 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 strong_ordering 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const month& m);
// 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 strong_ordering 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year& y);
// 25.8.6, class weekday // C++20
class weekday;
@@ -368,6 +375,9 @@ 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
// 25.8.7, class weekday_indexed // C++20
@@ -375,32 +385,39 @@ 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
+
// 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
+
// 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;
+constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const month_day& md);
// 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;
+constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
+
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
// 25.8.11, class month_weekday // C++20
class month_weekday;
@@ -408,22 +425,26 @@ 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
+
// 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
+
// 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 strong_ordering 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;
@@ -433,15 +454,15 @@ 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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
+
// 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 strong_ordering 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;
@@ -450,22 +471,15 @@ constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) n
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;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
// 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 bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
+constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
constexpr year_month_day_last
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
@@ -480,6 +494,10 @@ constexpr year_month_day_last
constexpr year_month_day_last
operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
+
// 25.8.16, class year_month_weekday // C++20
class year_month_weekday;
@@ -501,6 +519,10 @@ constexpr year_month_weekday
constexpr year_month_weekday
operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
+
// 25.8.17, class year_month_weekday_last // C++20
class year_month_weekday_last;
@@ -521,6 +543,10 @@ constexpr year_month_weekday_last
constexpr year_month_weekday_last
operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
+template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
+
// 25.8.18, civil calendar conventional syntax operators // C++20
constexpr year_month
operator/(const year& y, const month& m) noexcept;
@@ -645,7 +671,29 @@ 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;
+} // chrono
+
+namespace std {
+ template<class Rep, class Period, class charT>
+ struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
+ template<class charT> struct formatter<chrono::day, charT>; // C++20
+ template<class charT> struct formatter<chrono::month, charT>; // C++20
+ template<class charT> struct formatter<chrono::year, charT>; // C++20
+ template<class charT> struct formatter<chrono::weekday, charT>; // C++20
+ template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20
+ template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20
+ template<class charT> struct formatter<chrono::month_day, charT>; // C++20
+ template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20
+ template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20
+ template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20
+ template<class charT> struct formatter<chrono::year_month, charT>; // C++20
+ template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20
+ template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20
+ template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20
+ template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
+} // namespace std
+namespace chrono {
// calendrical constants
inline constexpr last_spec last{}; // C++20
inline constexpr chrono::weekday Sunday{0}; // C++20
@@ -695,6 +743,7 @@ constexpr chrono::year operator ""y(unsigned lo
#include <__assert> // all public C++ headers provide the assertion handler
#include <__chrono/calendar.h>
#include <__chrono/convert_to_timespec.h>
+#include <__chrono/convert_to_tm.h>
#include <__chrono/day.h>
#include <__chrono/duration.h>
#include <__chrono/file_clock.h>
@@ -716,10 +765,24 @@ constexpr chrono::year operator ""y(unsigned lo
#include <version>
// standard-mandated includes
+
+// [time.syn]
#include <compare>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) && _LIBCPP_STD_VER > 17
+# include <__chrono/formatter.h>
+# include <__chrono/ostream.h>
+# include <__chrono/parser_std_format_spec.h>
+# include <__chrono/statically_widen.h>
+#endif
+
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+#endif
+
#endif // _LIBCPP_CHRONO
diff --git a/libcxx/include/cinttypes b/libcxx/include/cinttypes
index a4cfe961cc55..a5b9558abde1 100644
--- a/libcxx/include/cinttypes
+++ b/libcxx/include/cinttypes
@@ -236,9 +236,22 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
+// standard-mandated includes
+
+// [cinttypes.syn]
#include <cstdint>
+
#include <inttypes.h>
+#ifndef _LIBCPP_INTTYPES_H
+# error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/climits b/libcxx/include/climits
index 16800a652f6d..d773af50d299 100644
--- a/libcxx/include/climits
+++ b/libcxx/include/climits
@@ -39,8 +39,17 @@ Macros:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <limits.h>
+#ifndef _LIBCPP_LIMITS_H
+# error <climits> tried including <limits.h> but didn't find libc++'s <limits.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/clocale b/libcxx/include/clocale
index 892604207532..e2ace355d7b6 100644
--- a/libcxx/include/clocale
+++ b/libcxx/include/clocale
@@ -36,8 +36,17 @@ lconv* localeconv();
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <locale.h>
+#ifndef _LIBCPP_LOCALE_H
+# error <clocale> tried including <locale.h> but didn't find libc++'s <locale.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 4d81eed339d8..a27d0ebceb35 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -306,10 +306,24 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <math.h>
-#include <type_traits>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
#include <version>
+#include <math.h>
+
+#ifndef _LIBCPP_MATH_H
+# error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -549,14 +563,14 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
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);
+ return std::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
+__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isnan)
return __builtin_isnan(__lcpp_x);
@@ -568,15 +582,15 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
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
+__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
{
- return isnan(__lcpp_x);
+ return std::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
+__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isinf)
return __builtin_isinf(__lcpp_x);
@@ -588,15 +602,15 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
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
+__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
{
- return isinf(__lcpp_x);
+ return std::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
+__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isfinite)
return __builtin_isfinite(__lcpp_x);
@@ -608,14 +622,169 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
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
+__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
{
- return isfinite(__lcpp_x);
+ return __builtin_isfinite(__lcpp_x);
+}
+
+_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT {
+ return __builtin_copysignf(__x, __y);
+}
+
+_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT {
+ return __builtin_copysign(__x, __y);
+}
+
+_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double
+__constexpr_copysign(long double __x, long double __y) _NOEXCEPT {
+ return __builtin_copysignl(__x, __y);
+}
+
+template <class _A1, class _A2>
+_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI
+ typename std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2> >::type
+ __constexpr_copysign(_A1 __x, _A2 __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 __builtin_copysign((__result_type)__x, (__result_type)__y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT {
+ return __builtin_fabsf(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT {
+ return __builtin_fabs(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT {
+ return __builtin_fabsl(__x);
+}
+
+template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT {
+ return __builtin_fabs(static_cast<double>(__x));
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT {
+#if !__has_constexpr_builtin(__builtin_fmaxf)
+ if (__libcpp_is_constant_evaluated()) {
+ if (std::__constexpr_isnan(__x))
+ return __y;
+ if (std::__constexpr_isnan(__y))
+ return __x;
+ return __x < __y ? __y : __x;
+ }
+#endif
+ return __builtin_fmaxf(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT {
+#if !__has_constexpr_builtin(__builtin_fmax)
+ if (__libcpp_is_constant_evaluated()) {
+ if (std::__constexpr_isnan(__x))
+ return __y;
+ if (std::__constexpr_isnan(__y))
+ return __x;
+ return __x < __y ? __y : __x;
+ }
+#endif
+ return __builtin_fmax(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double
+__constexpr_fmax(long double __x, long double __y) _NOEXCEPT {
+#if !__has_constexpr_builtin(__builtin_fmaxl)
+ if (__libcpp_is_constant_evaluated()) {
+ if (std::__constexpr_isnan(__x))
+ return __y;
+ if (std::__constexpr_isnan(__y))
+ return __x;
+ return __x < __y ? __y : __x;
+ }
+#endif
+ return __builtin_fmaxl(__x, __y);
+}
+
+template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type
+__constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT {
+ using __result_type = typename __promote<_Tp, _Up>::type;
+ return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) {
+#if !__has_constexpr_builtin(__builtin_logb)
+ if (__libcpp_is_constant_evaluated()) {
+ if (__x == _Tp(0)) {
+ // raise FE_DIVBYZERO
+ return -numeric_limits<_Tp>::infinity();
+ }
+
+ if (std::__constexpr_isinf(__x))
+ return numeric_limits<_Tp>::infinity();
+
+ if (std::__constexpr_isnan(__x))
+ return numeric_limits<_Tp>::quiet_NaN();
+
+ __x = std::__constexpr_fabs(__x);
+ unsigned long long __exp = 0;
+ while (__x >= numeric_limits<_Tp>::radix) {
+ __x /= numeric_limits<_Tp>::radix;
+ __exp += 1;
+ }
+ return _Tp(__exp);
+ }
+#endif // !__has_constexpr_builtin(__builtin_logb)
+ return __builtin_logb(__x);
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) {
+#if !__has_constexpr_builtin(__builtin_scalbln)
+ if (__libcpp_is_constant_evaluated()) {
+ if (__x == _Tp(0))
+ return __x;
+
+ if (std::__constexpr_isinf(__x))
+ return __x;
+
+ if (__exp == _Tp(0))
+ return __x;
+
+ if (std::__constexpr_isnan(__x))
+ return numeric_limits<_Tp>::quiet_NaN();
+
+ _Tp __mult(1);
+ if (__exp > 0) {
+ __mult = numeric_limits<_Tp>::radix;
+ --__exp;
+ } else {
+ ++__exp;
+ __exp = -__exp;
+ __mult /= numeric_limits<_Tp>::radix;
+ }
+
+ while (__exp > 0) {
+ if (!(__exp & 1)) {
+ __mult *= __mult;
+ __exp >>= 1;
+ } else {
+ __x *= __mult;
+ --__exp;
+ }
+ }
+ return __x;
+ }
+#endif // !__has_constexpr_builtin(__builtin_scalbln)
+ return __builtin_scalbn(__x, __exp);
}
#if _LIBCPP_STD_VER > 17
template <typename _Fp>
-constexpr
+_LIBCPP_HIDE_FROM_ABI 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;
@@ -628,13 +797,13 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
return __x < __b ? __x : __b;
}
-constexpr float
+_LIBCPP_HIDE_FROM_ABI constexpr float
lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
-constexpr double
+_LIBCPP_HIDE_FROM_ABI constexpr double
lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
-constexpr long double
+_LIBCPP_HIDE_FROM_ABI 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>
@@ -652,7 +821,7 @@ lerp(_A1 __a, _A2 __b, _A3 __t) noexcept
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);
+ return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
}
#endif // _LIBCPP_STD_VER > 17
@@ -660,4 +829,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_CMATH
diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt
index 9f18a7b1a989..ce378c8d1c6b 100644
--- a/libcxx/include/codecvt
+++ b/libcxx/include/codecvt
@@ -81,9 +81,9 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
: public codecvt<wchar_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
+ unsigned long __maxcode_;
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- codecvt_mode _Mode_;
+ codecvt_mode __mode_;
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
@@ -94,26 +94,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
_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) {}
+ : codecvt<wchar_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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -122,8 +118,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
: public codecvt<char16_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char16_t intern_type;
typedef char extern_type;
@@ -132,27 +128,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -160,8 +152,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
: public codecvt<char32_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char32_t intern_type;
typedef char extern_type;
@@ -170,27 +162,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -218,9 +206,9 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
: public codecvt<wchar_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
+ unsigned long __maxcode_;
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- codecvt_mode _Mode_;
+ codecvt_mode __mode_;
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
@@ -231,35 +219,32 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
_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) {}
+ : codecvt<wchar_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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+ size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
: public codecvt<wchar_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
+ unsigned long __maxcode_;
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- codecvt_mode _Mode_;
+ codecvt_mode __mode_;
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
@@ -270,26 +255,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
_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) {}
+ : codecvt<wchar_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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -298,8 +279,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
: public codecvt<char16_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char16_t intern_type;
typedef char extern_type;
@@ -308,27 +289,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -336,8 +313,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
: public codecvt<char16_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char16_t intern_type;
typedef char extern_type;
@@ -346,27 +323,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -374,8 +347,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
: public codecvt<char32_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char32_t intern_type;
typedef char extern_type;
@@ -384,27 +357,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -412,8 +381,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
: public codecvt<char32_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char32_t intern_type;
typedef char extern_type;
@@ -422,27 +391,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -470,9 +435,9 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
: public codecvt<wchar_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
+ unsigned long __maxcode_;
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- codecvt_mode _Mode_;
+ codecvt_mode __mode_;
_LIBCPP_SUPPRESS_DEPRECATED_POP
public:
typedef wchar_t intern_type;
@@ -483,26 +448,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
_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) {}
+ : codecvt<wchar_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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -511,8 +472,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
: public codecvt<char32_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char32_t intern_type;
typedef char extern_type;
@@ -521,27 +482,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -549,8 +506,8 @@ template <>
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
: public codecvt<char16_t, char, mbstate_t>
{
- unsigned long _Maxcode_;
- codecvt_mode _Mode_;
+ unsigned long __maxcode_;
+ codecvt_mode __mode_;
public:
typedef char16_t intern_type;
typedef char extern_type;
@@ -559,27 +516,23 @@ public:
_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) {}
+ : 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;
+ 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 override;
+ 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 override;
+ result do_unshift(state_type& __st,
+ extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
+ int do_encoding() const _NOEXCEPT override;
+ bool do_always_noconv() const _NOEXCEPT override;
+ int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
+ int do_max_length() const _NOEXCEPT override;
};
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
@@ -600,4 +553,19 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <cstddef>
+# include <cstdlib>
+# include <cstring>
+# include <initializer_list>
+# include <iosfwd>
+# include <limits>
+# include <new>
+# include <stdexcept>
+# include <type_traits>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_CODECVT
diff --git a/libcxx/include/compare b/libcxx/include/compare
index 6aa1abefd3ef..9272dbf62b14 100644
--- a/libcxx/include/compare
+++ b/libcxx/include/compare
@@ -160,4 +160,8 @@ namespace std {
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_COMPARE
diff --git a/libcxx/include/complex b/libcxx/include/complex
index 87a4e5872497..760fbaa81128 100644
--- a/libcxx/include/complex
+++ b/libcxx/include/complex
@@ -29,21 +29,21 @@ public:
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>&);
+ void real(T); // constexpr in C++20
+ void imag(T); // constexpr in C++20
+
+ complex<T>& operator= (const T&); // constexpr in C++20
+ complex<T>& operator+=(const T&); // constexpr in C++20
+ complex<T>& operator-=(const T&); // constexpr in C++20
+ complex<T>& operator*=(const T&); // constexpr in C++20
+ complex<T>& operator/=(const T&); // constexpr in C++20
+
+ complex& operator=(const complex&); // constexpr in C++20
+ template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -57,22 +57,22 @@ public:
explicit constexpr complex(const complex<long double>&);
constexpr float real() const;
- void real(float);
+ void real(float); // constexpr in C++20
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>&);
+ void imag(float); // constexpr in C++20
+
+ complex<float>& operator= (float); // constexpr in C++20
+ complex<float>& operator+=(float); // constexpr in C++20
+ complex<float>& operator-=(float); // constexpr in C++20
+ complex<float>& operator*=(float); // constexpr in C++20
+ complex<float>& operator/=(float); // constexpr in C++20
+
+ complex<float>& operator=(const complex<float>&); // constexpr in C++20
+ template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -86,22 +86,22 @@ public:
explicit constexpr complex(const complex<long double>&);
constexpr double real() const;
- void real(double);
+ void real(double); // constexpr in C++20
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>&);
+ void imag(double); // constexpr in C++20
+
+ complex<double>& operator= (double); // constexpr in C++20
+ complex<double>& operator+=(double); // constexpr in C++20
+ complex<double>& operator-=(double); // constexpr in C++20
+ complex<double>& operator*=(double); // constexpr in C++20
+ complex<double>& operator/=(double); // constexpr in C++20
+ complex<double>& operator=(const complex<double>&); // constexpr in C++20
+
+ template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -115,39 +115,39 @@ public:
constexpr complex(const complex<double>&);
constexpr long double real() const;
- void real(long double);
+ void real(long double); // constexpr in C++20
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>&);
+ void imag(long double); // constexpr in C++20
+
+ complex<long double>& operator=(const complex<long double>&); // constexpr in C++20
+ complex<long double>& operator= (long double); // constexpr in C++20
+ complex<long double>& operator+=(long double); // constexpr in C++20
+ complex<long double>& operator-=(long double); // constexpr in C++20
+ complex<long double>& operator*=(long double); // constexpr in C++20
+ complex<long double>& operator/=(long double); // constexpr in C++20
+
+ template<class X> complex<long double>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20
};
// 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> complex<T> operator+(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator+(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator+(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator-(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator*(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator*(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator*(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator/(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator/(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20
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
@@ -184,17 +184,17 @@ template<class T> T arg(const complex<T>&);
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> T norm(const complex<T>&); // constexpr in C++20
+ long double norm(long double); // constexpr in C++20
+ double norm(double); // constexpr in C++20
+template<Integral T> double norm(T); // constexpr in C++20
+ float norm(float); // constexpr in C++20
-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> conj(const complex<T>&); // constexpr in C++20
+ complex<long double> conj(long double); // constexpr in C++20
+ complex<double> conj(double); // constexpr in C++20
+template<Integral T> complex<double> conj(T); // constexpr in C++20
+ complex<float> conj(float); // constexpr in C++20
template<class T> complex<T> proj(const complex<T>&);
complex<long double> proj(long double);
@@ -251,8 +251,8 @@ _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> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
+template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template<class _Tp>
class _LIBCPP_TEMPLATE_VIS complex
@@ -263,50 +263,50 @@ private:
value_type __re_;
value_type __im_;
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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 _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 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 _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -334,40 +334,40 @@ public:
_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 _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(float __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(float __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -392,40 +392,40 @@ public:
_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 _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -450,40 +450,40 @@ public:
_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 _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(long double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(long double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -523,7 +523,7 @@ complex<long double>::complex(const complex<double>& __c)
// 26.3.6 operators:
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -533,7 +533,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -543,7 +543,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -553,7 +553,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -563,7 +563,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -573,7 +573,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -583,53 +583,86 @@ operator-(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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();
+
+ // Avoid floating point operations that are invalid during constant evaluation
+ if (__libcpp_is_constant_evaluated()) {
+ bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
+ bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
+ bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
+ bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
+ bool __z_nan = !__z_inf && (
+ (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
+ || (std::__constexpr_isnan(__a) && __b == _Tp(0))
+ || (__a == _Tp(0) && std::__constexpr_isnan(__b))
+ );
+ bool __w_nan = !__w_inf && (
+ (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
+ || (std::__constexpr_isnan(__c) && __d == _Tp(0))
+ || (__c == _Tp(0) && std::__constexpr_isnan(__d))
+ );
+ if (__z_nan || __w_nan) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ if (__z_inf || __w_inf) {
+ if (__z_zero || __w_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
+ bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
+ if (__z_nonzero_nan || __w_nonzero_nan) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ }
+
_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))
+ if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
{
bool __recalc = false;
- if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
+ if (std::__constexpr_isinf(__a) || std::__constexpr_isinf(__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);
+ __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ if (std::__constexpr_isnan(__c))
+ __c = std::__constexpr_copysign(_Tp(0), __c);
+ if (std::__constexpr_isnan(__d))
+ __d = std::__constexpr_copysign(_Tp(0), __d);
__recalc = true;
}
- if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
+ if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__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);
+ __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ if (std::__constexpr_isnan(__a))
+ __a = std::__constexpr_copysign(_Tp(0), __a);
+ if (std::__constexpr_isnan(__b))
+ __b = std::__constexpr_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 (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) ||
+ std::__constexpr_isinf(__ad) || std::__constexpr_isinf(__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);
+ if (std::__constexpr_isnan(__a))
+ __a = std::__constexpr_copysign(_Tp(0), __a);
+ if (std::__constexpr_isnan(__b))
+ __b = std::__constexpr_copysign(_Tp(0), __b);
+ if (std::__constexpr_isnan(__c))
+ __c = std::__constexpr_copysign(_Tp(0), __c);
+ if (std::__constexpr_isnan(__d))
+ __d = std::__constexpr_copysign(_Tp(0), __d);
__recalc = true;
}
if (__recalc)
@@ -642,7 +675,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator*(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -652,7 +685,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator*(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -662,7 +695,7 @@ operator*(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
{
int __ilogbw = 0;
@@ -670,34 +703,74 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_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))
+ _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d)));
+ if (std::__constexpr_isfinite(__logbw))
{
__ilogbw = static_cast<int>(__logbw);
- __c = scalbn(__c, -__ilogbw);
- __d = scalbn(__d, -__ilogbw);
+ __c = std::__constexpr_scalbn(__c, -__ilogbw);
+ __d = std::__constexpr_scalbn(__d, -__ilogbw);
+ }
+
+ // Avoid floating point operations that are invalid during constant evaluation
+ if (__libcpp_is_constant_evaluated()) {
+ bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
+ bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
+ bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
+ bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
+ bool __z_nan = !__z_inf && (
+ (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
+ || (std::__constexpr_isnan(__a) && __b == _Tp(0))
+ || (__a == _Tp(0) && std::__constexpr_isnan(__b))
+ );
+ bool __w_nan = !__w_inf && (
+ (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
+ || (std::__constexpr_isnan(__c) && __d == _Tp(0))
+ || (__c == _Tp(0) && std::__constexpr_isnan(__d))
+ );
+ if ((__z_nan || __w_nan) || (__z_inf && __w_inf)) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
+ bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
+ if (__z_nonzero_nan || __w_nonzero_nan) {
+ if (__w_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ if (__w_inf) {
+ return complex<_Tp>(_Tp(0), _Tp(0));
+ }
+ if (__z_inf) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ if (__w_zero) {
+ if (__z_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
}
+
_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))
+ _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
+ _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
+ if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
{
- if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
+ if ((__denom == _Tp(0)) && (!std::__constexpr_isnan(__a) || !std::__constexpr_isnan(__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 = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a;
+ __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b;
+ } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) &&
+ std::__constexpr_isfinite(__d)) {
+ __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = std::__constexpr_copysign(std::__constexpr_isinf(__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);
+ } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) &&
+ std::__constexpr_isfinite(__b)) {
+ __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d);
}
@@ -706,7 +779,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator/(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -714,7 +787,7 @@ operator/(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator/(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -724,7 +797,7 @@ operator/(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x)
{
@@ -732,7 +805,7 @@ operator+(const complex<_Tp>& __x)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x)
{
@@ -740,7 +813,7 @@ operator-(const complex<_Tp>& __x)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -748,7 +821,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -756,7 +829,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -764,7 +837,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -772,7 +845,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -780,7 +853,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -813,7 +886,7 @@ struct __libcpp_complex_overload_traits<_Tp, false, true>
// real
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
real(const complex<_Tp>& __c)
{
@@ -821,7 +894,7 @@ real(const complex<_Tp>& __c)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename __libcpp_complex_overload_traits<_Tp>::_ValueType
real(_Tp __re)
{
@@ -831,7 +904,7 @@ real(_Tp __re)
// imag
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
imag(const complex<_Tp>& __c)
{
@@ -839,7 +912,7 @@ imag(const complex<_Tp>& __c)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename __libcpp_complex_overload_traits<_Tp>::_ValueType
imag(_Tp)
{
@@ -853,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
abs(const complex<_Tp>& __c)
{
- return hypot(__c.real(), __c.imag());
+ return std::hypot(__c.real(), __c.imag());
}
// arg
@@ -863,7 +936,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
arg(const complex<_Tp>& __c)
{
- return atan2(__c.imag(), __c.real());
+ return std::atan2(__c.imag(), __c.real());
}
template <class _Tp>
@@ -874,7 +947,7 @@ typename enable_if<
>::type
arg(_Tp __re)
{
- return atan2l(0.L, __re);
+ return std::atan2l(0.L, __re);
}
template<class _Tp>
@@ -886,7 +959,7 @@ typename enable_if
>::type
arg(_Tp __re)
{
- return atan2(0., __re);
+ return std::atan2(0., __re);
}
template <class _Tp>
@@ -897,25 +970,25 @@ typename enable_if<
>::type
arg(_Tp __re)
{
- return atan2f(0.F, __re);
+ return std::atan2f(0.F, __re);
}
// norm
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_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());
+ if (std::__constexpr_isinf(__c.real()))
+ return std::abs(__c.real());
+ if (std::__constexpr_isinf(__c.imag()))
+ return std::abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __libcpp_complex_overload_traits<_Tp>::_ValueType
norm(_Tp __re)
{
@@ -926,7 +999,7 @@ norm(_Tp __re)
// conj
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
conj(const complex<_Tp>& __c)
{
@@ -934,7 +1007,7 @@ conj(const complex<_Tp>& __c)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
conj(_Tp __re)
{
@@ -952,8 +1025,8 @@ 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()));
+ if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))
+ __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
return __r;
}
@@ -966,8 +1039,8 @@ typename enable_if
>::type
proj(_Tp __re)
{
- if (__libcpp_isinf_or_builtin(__re))
- __re = abs(__re);
+ if (std::__constexpr_isinf(__re))
+ __re = std::abs(__re);
return complex<_Tp>(__re);
}
@@ -987,28 +1060,28 @@ proj(_Tp __re)
// polar
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp())
{
- if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
+ if (std::__constexpr_isnan(__rho) || std::signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
- if (__libcpp_isnan_or_builtin(__theta))
+ if (std::__constexpr_isnan(__theta))
{
- if (__libcpp_isinf_or_builtin(__rho))
+ if (std::__constexpr_isinf(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (__libcpp_isinf_or_builtin(__theta))
+ if (std::__constexpr_isinf(__theta))
{
- if (__libcpp_isinf_or_builtin(__rho))
+ if (std::__constexpr_isinf(__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))
+ _Tp __x = __rho * std::cos(__theta);
+ if (std::__constexpr_isnan(__x))
__x = 0;
- _Tp __y = __rho * sin(__theta);
- if (__libcpp_isnan_or_builtin(__y))
+ _Tp __y = __rho * std::sin(__theta);
+ if (std::__constexpr_isnan(__y))
__y = 0;
return complex<_Tp>(__x, __y);
}
@@ -1020,7 +1093,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
log(const complex<_Tp>& __x)
{
- return complex<_Tp>(log(abs(__x)), arg(__x));
+ return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x));
}
// log10
@@ -1030,52 +1103,52 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
log10(const complex<_Tp>& __x)
{
- return log(__x) / log(_Tp(10));
+ return std::log(__x) / std::log(_Tp(10));
}
// sqrt
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sqrt(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__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 complex<_Tp>(__x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
}
- return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
+ return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
}
// exp
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI 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()));
+ return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
if (__x.real() < _Tp(0))
{
- if (!__libcpp_isfinite_or_builtin(__i))
+ if (!std::__constexpr_isfinite(__i))
__i = _Tp(1);
}
- else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
+ else if (__i == 0 || !std::__constexpr_isfinite(__i))
{
- if (__libcpp_isinf_or_builtin(__i))
+ if (std::__constexpr_isinf(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
}
- _Tp __e = exp(__x.real());
- return complex<_Tp>(__e * cos(__i), __e * sin(__i));
+ _Tp __e = std::exp(__x.real());
+ return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i));
}
// pow
@@ -1085,7 +1158,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return std::exp(__y * std::log(__x));
}
template<class _Tp, class _Up>
@@ -1137,219 +1210,219 @@ __sqr(const complex<_Tp>& __x)
// asinh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
asinh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__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 (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__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()));
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
+ return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
}
// acosh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
acosh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__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 (std::__constexpr_isnan(__x.imag()))
+ return complex<_Tp>(std::abs(__x.real()), __x.imag());
+ if (std::__constexpr_isinf(__x.imag()))
{
if (__x.real() > 0)
- return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
else
- return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
+ return complex<_Tp>(-__x.real(), std::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()));
+ return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
- return complex<_Tp>(abs(__x.imag()), __x.real());
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::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()));
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
+ return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
}
// atanh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
atanh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
{
- return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
{
- if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
- return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
+ if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
}
- if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
+ if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
{
- return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(INFINITY), __x.real()), std::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()));
+ complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
+ return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
}
// sinh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sinh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
+ if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
+ if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
return __x;
- return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
+ return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));
}
// cosh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI 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()))
+ if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
+ return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
+ if (__x.real() == 0 && !std::__constexpr_isfinite(__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()));
+ if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
+ return complex<_Tp>(std::abs(__x.real()), __x.imag());
+ return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
}
// tanh
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
tanh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__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 (!std::__constexpr_isfinite(__x.imag()))
+ return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
+ return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
}
- if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
+ if (std::__constexpr_isnan(__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))
+ _Tp __d(std::cosh(__2r) + std::cos(__2i));
+ _Tp __2rsh(std::sinh(__2r));
+ if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__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);
+ return complex<_Tp>(__2rsh/__d, std::sin(__2i)/__d);
}
// asin
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
asin(const complex<_Tp>& __x)
{
- complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
// acos
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
acos(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__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());
+ return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
+ return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
- if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
+ if (__x.real() == 0 && (__x.imag() == 0 || std::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()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
+ if (std::signbit(__x.imag()))
+ return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real()));
+ return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real()));
}
// atan
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
atan(const complex<_Tp>& __x)
{
- complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
// sin
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sin(const complex<_Tp>& __x)
{
- complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
@@ -1360,26 +1433,27 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
cos(const complex<_Tp>& __x)
{
- return cosh(complex<_Tp>(-__x.imag(), __x.real()));
+ return std::cosh(complex<_Tp>(-__x.imag(), __x.real()));
}
// tan
template<class _Tp>
-complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI complex<_Tp>
tan(const complex<_Tp>& __x)
{
- complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template<class _Tp, class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
{
if (__is.good())
{
- ws(__is);
+ std::ws(__is);
if (__is.peek() == _CharT('('))
{
__is.get();
@@ -1387,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
__is >> __r;
if (!__is.fail())
{
- ws(__is);
+ std::ws(__is);
_CharT __c = __is.peek();
if (__c == _CharT(','))
{
@@ -1396,7 +1470,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
__is >> __i;
if (!__is.fail())
{
- ws(__is);
+ std::ws(__is);
__c = __is.peek();
if (__c == _CharT(')'))
{
@@ -1435,9 +1509,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
return __is;
}
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template<class _Tp, class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
{
basic_ostringstream<_CharT, _Traits> __s;
@@ -1455,34 +1528,34 @@ inline namespace literals
{
inline namespace complex_literals
{
- constexpr complex<long double> operator""il(long double __im)
+ _LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(long double __im)
{
return { 0.0l, __im };
}
- constexpr complex<long double> operator""il(unsigned long long __im)
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(long double __im)
{
return { 0.0, static_cast<double>(__im) };
}
- constexpr complex<double> operator""i(unsigned long long __im)
+ _LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(unsigned long long __im)
{
return { 0.0, static_cast<double>(__im) };
}
- constexpr complex<float> operator""if(long double __im)
+ _LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(long double __im)
{
return { 0.0f, static_cast<float>(__im) };
}
- constexpr complex<float> operator""if(unsigned long long __im)
+ _LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(unsigned long long __im)
{
return { 0.0f, static_cast<float>(__im) };
}
diff --git a/libcxx/include/complex.h b/libcxx/include/complex.h
index a2814669c7d4..a3da21c843f3 100644
--- a/libcxx/include/complex.h
+++ b/libcxx/include/complex.h
@@ -24,13 +24,9 @@
#endif
#ifdef __cplusplus
-
-#include <ccomplex>
-
-#else // __cplusplus
-
-#include_next <complex.h>
-
-#endif // __cplusplus
+# include <ccomplex>
+#elif __has_include_next(<complex.h>)
+# include_next <complex.h>
+#endif
#endif // _LIBCPP_COMPLEX_H
diff --git a/libcxx/include/concepts b/libcxx/include/concepts
index 301256ca7ef7..196fa2e0ea70 100644
--- a/libcxx/include/concepts
+++ b/libcxx/include/concepts
@@ -155,6 +155,10 @@ namespace std {
#include <__config>
#include <version>
+#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
+# include <type_traits>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/condition_variable b/libcxx/include/condition_variable
index 92088f3e1b22..f13df1c012fa 100644
--- a/libcxx/include/condition_variable
+++ b/libcxx/include/condition_variable
@@ -108,8 +108,9 @@ public:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__memory/shared_ptr.h>
+#include <__memory/unique_ptr.h>
#include <__mutex_base>
-#include <memory>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -267,4 +268,9 @@ _LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_CONDITION_VARIABLE
diff --git a/libcxx/include/coroutine b/libcxx/include/coroutine
index 6582f5554ed0..f264570128bb 100644
--- a/libcxx/include/coroutine
+++ b/libcxx/include/coroutine
@@ -46,15 +46,18 @@ struct suspend_always;
#include <__coroutine/trivial_awaitables.h>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iosfwd>
-#endif
-
// standard-mandated includes
+
+// [coroutine.syn]
#include <compare>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_COROUTINE
diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index 4f40bcbf61e9..4c64e8327e3f 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -32,8 +32,17 @@ void longjmp(jmp_buf env, int val);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <setjmp.h>
+#ifndef _LIBCPP_SETJMP_H
+# error <csetjmp> tried including <setjmp.h> but didn't find libc++'s <setjmp.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/csignal b/libcxx/include/csignal
index c1b58f818b62..cf45f507535e 100644
--- a/libcxx/include/csignal
+++ b/libcxx/include/csignal
@@ -42,8 +42,12 @@ int raise(int sig);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+// <signal.h> is not provided by libc++
#if __has_include(<signal.h>)
-# include <signal.h>
+# include <signal.h>
+# ifdef _LIBCPP_SIGNAL_H
+# error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>"
+# endif
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/cstdarg b/libcxx/include/cstdarg
index f36ade202b7a..3a4291f4584a 100644
--- a/libcxx/include/cstdarg
+++ b/libcxx/include/cstdarg
@@ -33,7 +33,14 @@ Types:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <stdarg.h>
+
+// <stdarg.h> is not provided by libc++
+#if __has_include(<stdarg.h>)
+# include <stdarg.h>
+# ifdef _LIBCPP_STDARG_H
+# error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index 8daba076d7db..e3c066917570 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -38,9 +38,18 @@ Types:
#include <__type_traits/enable_if.h>
#include <__type_traits/integral_constant.h>
#include <__type_traits/is_integral.h>
-#include <stddef.h>
#include <version>
+#include <stddef.h>
+
+#ifndef _LIBCPP_STDDEF_H
+# error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -62,7 +71,7 @@ namespace std // purposefully not versioned
{
enum class byte : unsigned char {};
-constexpr byte operator| (byte __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator| (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
@@ -70,10 +79,10 @@ constexpr byte operator| (byte __lhs, byte __rhs) noexcept
));
}
-constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs | __rhs; }
-constexpr byte operator& (byte __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator& (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
@@ -81,10 +90,10 @@ constexpr byte operator& (byte __lhs, byte __rhs) noexcept
));
}
-constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs & __rhs; }
-constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
@@ -92,10 +101,10 @@ constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
));
}
-constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs ^ __rhs; }
-constexpr byte operator~ (byte __b) noexcept
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator~ (byte __b) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
@@ -107,27 +116,27 @@ template <class _Tp>
using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
template <class _Integer>
- constexpr _EnableByteOverload<_Integer> &
+_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
operator<<=(byte& __lhs, _Integer __shift) noexcept
{ return __lhs = __lhs << __shift; }
template <class _Integer>
- constexpr _EnableByteOverload<_Integer>
+_LIBCPP_HIDE_FROM_ABI 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> &
+_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
operator>>=(byte& __lhs, _Integer __shift) noexcept
{ return __lhs = __lhs >> __shift; }
template <class _Integer>
- constexpr _EnableByteOverload<_Integer>
+_LIBCPP_HIDE_FROM_ABI 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
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
} // namespace std
diff --git a/libcxx/include/cstdint b/libcxx/include/cstdint
index 83cda947b497..829d9398f387 100644
--- a/libcxx/include/cstdint
+++ b/libcxx/include/cstdint
@@ -142,8 +142,17 @@ Types:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <stdint.h>
+#ifndef _LIBCPP_STDINT_H
+# error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio
index d191086a85da..221b0b314cf9 100644
--- a/libcxx/include/cstdio
+++ b/libcxx/include/cstdio
@@ -97,8 +97,17 @@ void perror(const char* s);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <stdio.h>
+#ifndef _LIBCPP_STDIO_H
+# error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index 457c31f625d8..25c9de5165c2 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -83,8 +83,17 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <stdlib.h>
+#ifndef _LIBCPP_STDLIB_H
+# error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/cstring b/libcxx/include/cstring
index 37c92e149b8f..c88d97739f74 100644
--- a/libcxx/include/cstring
+++ b/libcxx/include/cstring
@@ -58,8 +58,18 @@ size_t strlen(const char* s);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__type_traits/is_constant_evaluated.h>
+
#include <string.h>
+#ifndef _LIBCPP_STRING_H
+# error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -90,6 +100,53 @@ using ::memset _LIBCPP_USING_IF_EXISTS;
using ::strerror _LIBCPP_USING_IF_EXISTS;
using ::strlen _LIBCPP_USING_IF_EXISTS;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const char* __str) {
+ // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation.
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
+#ifdef _LIBCPP_COMPILER_GCC
+ if (__libcpp_is_constant_evaluated()) {
+ size_t __i = 0;
+ for (; __str[__i] != '\0'; ++__i)
+ ;
+ return __i;
+ }
+#endif
+ return __builtin_strlen(__str);
+}
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
+__constexpr_memcmp(const _Tp* __lhs, const _Tp* __rhs, size_t __count) {
+#ifdef _LIBCPP_COMPILER_GCC
+ if (__libcpp_is_constant_evaluated()) {
+ for (; __count; --__count, ++__lhs, ++__rhs) {
+ if (*__lhs < *__rhs)
+ return -1;
+ if (*__rhs < *__lhs)
+ return 1;
+ }
+ return 0;
+ }
+#endif
+ return __builtin_memcmp(__lhs, __rhs, __count);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const char*
+__constexpr_char_memchr(const char* __str, int __char, size_t __count) {
+#if __has_builtin(__builtin_char_memchr)
+ return __builtin_char_memchr(__str, __char, __count);
+#else
+ if (!__libcpp_is_constant_evaluated())
+ return static_cast<const char*>(std::memchr(__str, __char, __count));
+ for (; __count; --__count) {
+ if (*__str == __char)
+ return __str;
+ ++__str;
+ }
+ return nullptr;
+#endif
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTRING
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index 0c6e4dfd6f98..2293675b4941 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -47,7 +47,14 @@ int timespec_get( struct timespec *ts, int base); // C++17
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <time.h>
+
+// <time.h> is not provided by libc++
+#if __has_include(<time.h>)
+# include <time.h>
+# ifdef _LIBCPP_TIME_H
+# error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/ctype.h b/libcxx/include/ctype.h
index ba0925069c64..728173ed670f 100644
--- a/libcxx/include/ctype.h
+++ b/libcxx/include/ctype.h
@@ -35,7 +35,9 @@ int toupper(int c);
# pragma GCC system_header
#endif
-#include_next <ctype.h>
+#if __has_include_next(<ctype.h>)
+# include_next <ctype.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar
index a4ed585d1aeb..93e657e84b6d 100644
--- a/libcxx/include/cuchar
+++ b/libcxx/include/cuchar
@@ -25,6 +25,8 @@ Types:
mbstate_t
size_t
+size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps); // since C++20
+size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps); // since C++20
size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
@@ -36,8 +38,17 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+
#include <uchar.h>
+#ifndef _LIBCPP_UCHAR_H
+# error <cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -49,6 +60,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
using ::size_t _LIBCPP_USING_IF_EXISTS;
+# if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
+using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
+using ::c8rtomb _LIBCPP_USING_IF_EXISTS;
+# endif
using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index 5c69ab2a7bb1..fb7b92b760af 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -104,9 +104,19 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__type_traits/is_constant_evaluated.h>
#include <cwctype>
+
#include <wchar.h>
+#ifndef _LIBCPP_WCHAR_H
+# error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -180,6 +190,55 @@ using ::putwchar _LIBCPP_USING_IF_EXISTS;
using ::vwprintf _LIBCPP_USING_IF_EXISTS;
using ::wprintf _LIBCPP_USING_IF_EXISTS;
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {
+#if __has_builtin(__builtin_wcslen)
+ return __builtin_wcslen(__str);
+#else
+ if (!__libcpp_is_constant_evaluated())
+ return std::wcslen(__str);
+
+ size_t __len = 0;
+ for (; *__str != L'\0'; ++__str)
+ ++__len;
+ return __len;
+#endif
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
+__constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {
+#if __has_builtin(__builtin_wmemcmp)
+ return __builtin_wmemcmp(__lhs, __rhs, __count);
+#else
+ if (!__libcpp_is_constant_evaluated())
+ return std::wmemcmp(__lhs, __rhs, __count);
+
+ for (; __count; --__count, ++__lhs, ++__rhs) {
+ if (*__lhs < *__rhs)
+ return -1;
+ if (*__rhs < *__lhs)
+ return 1;
+ }
+ return 0;
+#endif
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const wchar_t*
+__constexpr_wmemchr(const wchar_t* __str, wchar_t __char, size_t __count) {
+#if __has_feature(cxx_constexpr_string_builtins)
+ return __builtin_wmemchr(__str, __char, __count);
+#else
+ if (!__libcpp_is_constant_evaluated())
+ return std::wmemchr(__str, __char, __count);
+
+ for (; __count; --__count) {
+ if (*__str == __char)
+ return __str;
+ ++__str;
+ }
+ return nullptr;
+#endif
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CWCHAR
diff --git a/libcxx/include/cwctype b/libcxx/include/cwctype
index 429b00c2446d..5a2d2427d847 100644
--- a/libcxx/include/cwctype
+++ b/libcxx/include/cwctype
@@ -52,8 +52,17 @@ wctrans_t wctrans(const char* property);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cctype>
+
#include <wctype.h>
+#ifndef _LIBCPP_WCTYPE_H
+# error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \
+ This usually means that your header search paths are not configured properly. \
+ The header search paths should contain the C++ Standard Library headers before \
+ any C Standard Library, and you are probably using compiler flags that make that \
+ not be the case.
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 0d7eb9aa9316..f2b8076c0af1 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -176,7 +176,14 @@ template <class T, class Allocator, class Predicate>
#include <__iterator/next.h>
#include <__iterator/prev.h>
#include <__iterator/reverse_iterator.h>
+#include <__iterator/segmented_iterator.h>
+#include <__memory/allocator_destructor.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/temp_value.h>
+#include <__memory/unique_ptr.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__split_buffer>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/swap.h>
@@ -185,12 +192,6 @@ template <class T, class Allocator, class Predicate>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -214,101 +215,8 @@ _LIBCPP_PUSH_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 value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
@@ -340,22 +248,22 @@ public:
typedef random_access_iterator_tag iterator_category;
typedef _Reference reference;
- _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __m_iter_(nullptr), __ptr_(nullptr)
#endif
{}
template <class _Pp, class _Rp, class _MP>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
__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_HIDE_FROM_ABI reference operator*() const {return *__ptr_;}
+ _LIBCPP_HIDE_FROM_ABI pointer operator->() const {return __ptr_;}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator++()
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator++()
{
if (++__ptr_ - *__m_iter_ == __block_size)
{
@@ -365,14 +273,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator operator++(int)
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator operator++(int)
{
__deque_iterator __tmp = *this;
++(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator--()
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator--()
{
if (__ptr_ == *__m_iter_)
{
@@ -383,14 +291,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator operator--(int)
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator operator--(int)
{
__deque_iterator __tmp = *this;
--(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator+=(difference_type __n)
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator+=(difference_type __n)
{
if (__n != 0)
{
@@ -410,30 +318,30 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator-=(difference_type __n)
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator-=(difference_type __n)
{
return *this += -__n;
}
- _LIBCPP_INLINE_VISIBILITY __deque_iterator operator+(difference_type __n) const
+ _LIBCPP_HIDE_FROM_ABI __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
+ _LIBCPP_HIDE_FROM_ABI __deque_iterator operator-(difference_type __n) const
{
__deque_iterator __t(*this);
__t -= __n;
return __t;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)
{return __it + __n;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)
{
if (__x != __y)
@@ -443,142 +351,72 @@ public:
return 0;
}
- _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
+ _LIBCPP_HIDE_FROM_ABI reference operator[](difference_type __n) const
{return *(*this + __n);}
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)
{return __x.__ptr_ == __y.__ptr_;}
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)
{return !(__x == __y);}
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI 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
+ _LIBCPP_HIDE_FROM_ABI friend
bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)
{return __y < __x;}
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)
{return !(__y < __x);}
- _LIBCPP_INLINE_VISIBILITY friend
+ _LIBCPP_HIDE_FROM_ABI friend
bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)
{return !(__x < __y);}
private:
- _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI explicit __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>
+ friend struct __segmented_iterator_traits;
+};
+
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize>
+struct __segmented_iterator_traits<
+ __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > {
+private:
+ using _Iterator = __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;
+
+public:
+ using __is_segmented_iterator = true_type;
+ using __segment_iterator = _MapPointer;
+ using __local_iterator = _Pointer;
+
+ static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }
+ static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; }
+ static _LIBCPP_HIDE_FROM_ABI __local_iterator __begin(__segment_iterator __iter) { return *__iter; }
+
+ static _LIBCPP_HIDE_FROM_ABI __local_iterator __end(__segment_iterator __iter) {
+ return *__iter + _Iterator::__block_size;
+ }
+
+ static _LIBCPP_HIDE_FROM_ABI _Iterator __compose(__segment_iterator __segment, __local_iterator __local) {
+ if (__local == __end(__segment)) {
+ ++__segment;
+ return _Iterator(__segment, *__segment);
+ }
+ return _Iterator(__segment, __local);
+ }
};
template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
@@ -587,897 +425,329 @@ 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*)
+template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
+class _LIBCPP_TEMPLATE_VIS deque
{
- 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;
-}
+public:
+ // types:
-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;
-}
+ using value_type = _Tp;
-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;
-}
+ static_assert((is_same<typename _Allocator::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
-// copy_backward
+ using allocator_type = _Allocator;
+ using __alloc_traits = allocator_traits<allocator_type>;
-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;
-}
+ using size_type = typename __alloc_traits::size_type;
+ using difference_type = typename __alloc_traits::difference_type;
-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;
-}
+ using pointer = typename __alloc_traits::pointer;
+ using const_pointer = typename __alloc_traits::const_pointer;
-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;
-}
+ using __pointer_allocator = __rebind_alloc<__alloc_traits, pointer>;
+ using __const_pointer_allocator = __rebind_alloc<__alloc_traits, const_pointer>;
+ using __map = __split_buffer<pointer, __pointer_allocator>;
+ using __map_alloc_traits = allocator_traits<__pointer_allocator>;
+ using __map_pointer = typename __map_alloc_traits::pointer;
+ using __map_const_pointer = typename allocator_traits<__const_pointer_allocator>::const_pointer;
-// move
+ using reference = value_type&;
+ using const_reference = const value_type&;
-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;
-}
+ using iterator = __deque_iterator<value_type, pointer, reference, __map_pointer, difference_type>;
+ using const_iterator =
+ __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer, difference_type>;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-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;
-}
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+ static_assert(is_nothrow_default_constructible<allocator_type>::value ==
+ is_nothrow_default_constructible<__pointer_allocator>::value,
+ "rebinding an allocator should not change excpetion guarantees");
+ static_assert(is_nothrow_move_constructible<allocator_type>::value ==
+ is_nothrow_move_constructible<typename __map::allocator_type>::value,
+ "rebinding an allocator should not change excpetion guarantees");
-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;
-}
+private:
+ struct __deque_block_range {
+ explicit _LIBCPP_HIDE_FROM_ABI
+ __deque_block_range(pointer __b, pointer __e) _NOEXCEPT : __begin_(__b), __end_(__e) {}
+ const pointer __begin_;
+ const pointer __end_;
+ };
-// move_backward
+ struct __deque_range {
+ iterator __pos_;
+ const iterator __end_;
-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;
-}
+ _LIBCPP_HIDE_FROM_ABI __deque_range(iterator __pos, iterator __e) _NOEXCEPT
+ : __pos_(__pos), __end_(__e) {}
-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;
+ explicit _LIBCPP_HIDE_FROM_ABI operator bool() const _NOEXCEPT {
+ return __pos_ != __end_;
}
- 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;
+ _LIBCPP_HIDE_FROM_ABI __deque_range begin() const {
+ return *this;
}
- 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 {
+ _LIBCPP_HIDE_FROM_ABI __deque_range end() const {
+ return __deque_range(__end_, __end_);
+ }
+ _LIBCPP_HIDE_FROM_ABI __deque_block_range operator*() const _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_;
+ return __deque_block_range(__pos_.__ptr_, __end_.__ptr_);
}
- 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) {}
-
+ return __deque_block_range(__pos_.__ptr_, *__pos_.__m_iter_ + __block_size);
+ }
- ~_ConstructTransaction() {
- __base_->size() += (__pos_ - __begin_);
+ _LIBCPP_HIDE_FROM_ABI __deque_range& operator++() _NOEXCEPT {
+ if (__pos_.__m_iter_ == __end_.__m_iter_) {
+ __pos_ = __end_;
+ } else {
+ ++__pos_.__m_iter_;
+ __pos_.__ptr_ = *__pos_.__m_iter_;
}
-
- 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;
+ return *this;
}
- _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;
+ _LIBCPP_HIDE_FROM_ABI friend bool operator==(__deque_range const& __lhs, __deque_range const& __rhs) {
+ return __lhs.__pos_ == __rhs.__pos_;
}
- else
- {
- if (size() != 0)
- return false;
- if (__start_ != 0)
- return false;
+ _LIBCPP_HIDE_FROM_ABI friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {
+ return !(__lhs == __rhs);
}
- 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);
-}
+ struct _ConstructTransaction {
+ _LIBCPP_HIDE_FROM_ABI _ConstructTransaction(deque* __db, __deque_block_range& __r)
+ : __pos_(__r.__begin_), __end_(__r.__end_), __begin_(__r.__begin_), __base_(__db) {}
-#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;
+ _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
+ __base_->__size() += (__pos_ - __begin_);
}
- else
- {
- __map_.clear();
- __start_ = 0;
- size() = 0;
- }
-}
-#endif // _LIBCPP_CXX03_LANG
+ pointer __pos_;
+ const pointer __end_;
+ private:
+ const pointer __begin_;
+ deque* const __base_;
+ };
-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());
-}
+ static const difference_type __block_size;
-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;
- }
-}
+ __map __map_;
+ size_type __start_;
+ __compressed_pair<size_type, allocator_type> __size_;
-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;
+ // construct/copy/destroy:
+ _LIBCPP_HIDE_FROM_ABI
+ deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __start_(0), __size_(0, __default_init_tag()) {}
- 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;
+ _LIBCPP_HIDE_FROM_ABI ~deque() {
+ clear();
+ typename __map::iterator __i = __map_.begin();
+ typename __map::iterator __e = __map_.end();
+ for (; __i != __e; ++__i)
+ __alloc_traits::deallocate(__alloc(), *__i, __block_size);
+ }
- using typename __base::__deque_range;
- using typename __base::__deque_block_range;
- using typename __base::_ConstructTransaction;
+ _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
- // 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);
+ explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit deque(size_type __n, const _Allocator& __a);
+ explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);
#endif
- deque(size_type __n, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI 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)
+ _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
{
if (__n > 0)
__append(__n, __v);
}
template <class _InputIter>
- deque(_InputIter __f, _InputIter __l,
+ _LIBCPP_HIDE_FROM_ABI 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,
+ _LIBCPP_HIDE_FROM_ABI 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 __type_identity_t<allocator_type>& __a);
+ _LIBCPP_HIDE_FROM_ABI deque(const deque& __c);
+ _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
- deque& operator=(const deque& __c);
+ _LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI deque(initializer_list<value_type> __il);
+ _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
+ deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+ _LIBCPP_HIDE_FROM_ABI
deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
deque& operator=(deque&& __c)
_NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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,
+ _LIBCPP_HIDE_FROM_ABI 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,
+ _LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); }
+ _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); }
+
+ // iterators:
+
+ _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
+ __map_pointer __mp = __map_.begin() + __start_ / __block_size;
+ return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI const_iterator 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);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI iterator 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);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI const_iterator 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);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
reverse_iterator rbegin() _NOEXCEPT
- {return reverse_iterator(__base::end());}
- _LIBCPP_INLINE_VISIBILITY
+ {return reverse_iterator(end());}
+ _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator rbegin() const _NOEXCEPT
- {return const_reverse_iterator(__base::end());}
- _LIBCPP_INLINE_VISIBILITY
+ {return const_reverse_iterator(end());}
+ _LIBCPP_HIDE_FROM_ABI
reverse_iterator rend() _NOEXCEPT
- {return reverse_iterator(__base::begin());}
- _LIBCPP_INLINE_VISIBILITY
+ {return reverse_iterator(begin());}
+ _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator rend() const _NOEXCEPT
- {return const_reverse_iterator(__base::begin());}
+ {return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const_iterator cbegin() const _NOEXCEPT
- {return __base::begin();}
- _LIBCPP_INLINE_VISIBILITY
+ {return begin();}
+ _LIBCPP_HIDE_FROM_ABI
const_iterator cend() const _NOEXCEPT
- {return __base::end();}
- _LIBCPP_INLINE_VISIBILITY
+ {return end();}
+ _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator crbegin() const _NOEXCEPT
- {return const_reverse_iterator(__base::end());}
- _LIBCPP_INLINE_VISIBILITY
+ {return const_reverse_iterator(end());}
+ _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator crend() const _NOEXCEPT
- {return const_reverse_iterator(__base::begin());}
+ {return const_reverse_iterator(begin());}
// capacity:
- _LIBCPP_INLINE_VISIBILITY
- size_type size() const _NOEXCEPT {return __base::size();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
+ size_type size() const _NOEXCEPT {return __size();}
+
+ _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_.first(); }
+ _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_.first(); }
+
+ _LIBCPP_HIDE_FROM_ABI
size_type max_size() const _NOEXCEPT
{return _VSTD::min<size_type>(
- __alloc_traits::max_size(__base::__alloc()),
+ __alloc_traits::max_size(__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;}
+ _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+ bool empty() const _NOEXCEPT {return size() == 0;}
// element access:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
reference operator[](size_type __i) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const_reference operator[](size_type __i) const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
reference at(size_type __i);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const_reference at(size_type __i) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
reference front() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const_reference front() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
reference back() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
const_reference back() const _NOEXCEPT;
// 23.2.2.3 modifiers:
- void push_front(const value_type& __v);
- void push_back(const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI 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);
+ template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
+ template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_back (_Args&&... __args);
#else
- template <class... _Args> void emplace_front(_Args&&... __args);
- template <class... _Args> void emplace_back (_Args&&... __args);
+ template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
+ template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_back (_Args&&... __args);
#endif
- template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args);
+ template <class... _Args> _LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI void push_front(value_type&& __v);
+ _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v);
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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);
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIter>
- iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);
template <class _ForwardIterator>
- iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _BiIter>
- iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
+ _LIBCPP_HIDE_FROM_ABI 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_HIDE_FROM_ABI void pop_front();
+ _LIBCPP_HIDE_FROM_ABI void pop_back();
+ _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
+ _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void swap(deque& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
@@ -1485,121 +755,177 @@ public:
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void clear() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- bool __invariants() const {return __base::__invariants();}
+ _LIBCPP_HIDE_FROM_ABI
+ bool __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;
+ }
- typedef typename __base::__map_const_pointer __map_const_pointer;
+ _LIBCPP_HIDE_FROM_ABI
+ void __move_assign_alloc(deque& __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_HIDE_FROM_ABI
+ void __move_assign_alloc(deque& __c, true_type)
+ _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ {
+ __alloc() = _VSTD::move(__c.__alloc());
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ void __move_assign_alloc(deque&, false_type) _NOEXCEPT
+ {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ void __move_assign(deque& __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
+ _LIBCPP_HIDE_FROM_ABI
static size_type __recommend_blocks(size_type __n)
{
- return __n / __base::__block_size + (__n % __base::__block_size != 0);
+ return __n / __block_size + (__n % __block_size != 0);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __capacity() const
{
- return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __base::__block_size - 1;
+ return __map_.size() == 0 ? 0 : __map_.size() * __block_size - 1;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __block_count() const
{
- return __base::__map_.size();
+ return __map_.size();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __front_spare() const
{
- return __base::__start_;
+ return __start_;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __front_spare_blocks() const {
- return __front_spare() / __base::__block_size;
+ return __front_spare() / __block_size;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __back_spare() const
{
- return __capacity() - (__base::__start_ + __base::size());
+ return __capacity() - (__start_ + size());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
size_type __back_spare_blocks() const {
- return __back_spare() / __base::__block_size;
+ return __back_spare() / __block_size;
}
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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;
+ __alloc_traits::deallocate(__alloc(), __map_.front(),
+ __block_size);
+ __map_.pop_front();
+ __start_ -= __block_size;
return true;
}
return false;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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();
+ __alloc_traits::deallocate(__alloc(), __map_.back(),
+ __block_size);
+ __map_.pop_back();
return true;
}
return false;
}
template <class _InpIter>
- void __append(_InpIter __f, _InpIter __l,
+ _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l,
typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);
template <class _ForIter>
- void __append(_ForIter __f, _ForIter __l,
+ _LIBCPP_HIDE_FROM_ABI 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,
+ _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI void __erase_to_end(const_iterator __f);
+ _LIBCPP_HIDE_FROM_ABI void __add_front_capacity();
+ _LIBCPP_HIDE_FROM_ABI void __add_front_capacity(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI void __add_back_capacity();
+ _LIBCPP_HIDE_FROM_ABI void __add_back_capacity(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI iterator __move_and_check(iterator __f, iterator __l, iterator __r,
const_pointer& __vt);
- iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
+ _LIBCPP_HIDE_FROM_ABI iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
const_pointer& __vt);
- void __move_construct_and_check(iterator __f, iterator __l,
+ _LIBCPP_HIDE_FROM_ABI void __move_construct_and_check(iterator __f, iterator __l,
iterator __r, const_pointer& __vt);
- void __move_construct_backward_and_check(iterator __f, iterator __l,
+ _LIBCPP_HIDE_FROM_ABI void __move_construct_backward_and_check(iterator __f, iterator __l,
iterator __r, const_pointer& __vt);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
void __copy_assign_alloc(const deque& __c, true_type)
{
- if (__base::__alloc() != __c.__alloc())
+ if (__alloc() != __c.__alloc())
{
clear();
shrink_to_fit();
}
- __base::__alloc() = __c.__alloc();
- __base::__map_.__alloc() = __c.__map_.__alloc();
+ __alloc() = __c.__alloc();
+ __map_.__alloc() = __c.__map_.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void __copy_assign_alloc(const deque&, false_type)
{}
- void __move_assign(deque& __c, true_type)
+ _LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- void __move_assign(deque& __c, false_type);
+ _LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, false_type);
};
+template <class _Tp, class _Alloc>
+_LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size =
+ __deque_block_size<value_type, difference_type>::value;
+
#if _LIBCPP_STD_VER >= 17
template<class _InputIterator,
class _Alloc = allocator<__iter_value_type<_InputIterator>>,
@@ -1620,6 +946,7 @@ deque(_InputIterator, _InputIterator, _Alloc)
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n)
+ : __start_(0), __size_(0, __default_init_tag())
{
if (__n > 0)
__append(__n);
@@ -1628,7 +955,7 @@ deque<_Tp, _Allocator>::deque(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
- : __base(__a)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
{
if (__n > 0)
__append(__n);
@@ -1637,6 +964,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
+ : __start_(0), __size_(0, __default_init_tag())
{
if (__n > 0)
__append(__n, __v);
@@ -1646,6 +974,7 @@ 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*)
+ : __start_(0), __size_(0, __default_init_tag())
{
__append(__f, __l);
}
@@ -1654,21 +983,23 @@ 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)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __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()))
+ : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))),
+ __start_(0),
+ __size_(0, __map_.__alloc())
{
__append(__c.begin(), __c.end());
}
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)
- : __base(__a)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
{
__append(__c.begin(), __c.end());
}
@@ -1689,13 +1020,14 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
+ : __start_(0), __size_(0, __default_init_tag())
{
__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)
+ : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
{
__append(__il.begin(), __il.end());
}
@@ -1703,18 +1035,30 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator
template <class _Tp, class _Allocator>
inline
deque<_Tp, _Allocator>::deque(deque&& __c)
- _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
- : __base(_VSTD::move(__c))
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+ : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_))
{
+ __c.__start_ = 0;
+ __c.__size() = 0;
}
template <class _Tp, class _Allocator>
inline
deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)
- : __base(_VSTD::move(__c), __a)
+ : __map_(std::move(__c.__map_), __pointer_allocator(__a)),
+ __start_(std::move(__c.__start_)),
+ __size_(std::move(__c.__size()), __a)
{
- if (__a != __c.__alloc())
+ if (__a == __c.__alloc())
{
+ __c.__start_ = 0;
+ __c.__size() = 0;
+ }
+ else
+ {
+ __map_.clear();
+ __start_ = 0;
+ __size() = 0;
typedef move_iterator<iterator> _Ip;
assign(_Ip(__c.begin()), _Ip(__c.end()));
}
@@ -1736,7 +1080,7 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)
{
- if (__base::__alloc() != __c.__alloc())
+ if (__alloc() != __c.__alloc())
{
typedef move_iterator<iterator> _Ip;
assign(_Ip(__c.begin()), _Ip(__c.end()));
@@ -1752,7 +1096,7 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
{
clear();
shrink_to_fit();
- __base::__move_assign(__c);
+ __move_assign(__c);
}
#endif // _LIBCPP_CXX03_LANG
@@ -1764,8 +1108,8 @@ 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();
+ iterator __i = begin();
+ iterator __e = end();
for (; __f != __l && __i != __e; ++__f, (void) ++__i)
*__i = *__f;
if (__f != __l)
@@ -1780,28 +1124,28 @@ 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())
+ if (static_cast<size_type>(__l - __f) > size())
{
- _RAIter __m = __f + __base::size();
- _VSTD::copy(__f, __m, __base::begin());
+ _RAIter __m = __f + size();
+ _VSTD::copy(__f, __m, begin());
__append(__m, __l);
}
else
- __erase_to_end(_VSTD::copy(__f, __l, __base::begin()));
+ __erase_to_end(_VSTD::copy(__f, __l, begin()));
}
template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
{
- if (__n > __base::size())
+ if (__n > size())
{
- _VSTD::fill_n(__base::begin(), __base::size(), __v);
- __n -= __base::size();
+ _VSTD::fill_n(begin(), size(), __v);
+ __n -= size();
__append(__n, __v);
}
else
- __erase_to_end(_VSTD::fill_n(__base::begin(), __n, __v));
+ __erase_to_end(_VSTD::fill_n(begin(), __n, __v));
}
template <class _Tp, class _Allocator>
@@ -1809,49 +1153,49 @@ inline
_Allocator
deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
{
- return __base::__alloc();
+ return __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);
+ if (__n > size())
+ __append(__n - size());
+ else if (__n < size())
+ __erase_to_end(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);
+ if (__n > size())
+ __append(__n - size(), __v);
+ else if (__n < size())
+ __erase_to_end(begin() + __n);
}
template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
if (empty())
{
- while (__base::__map_.size() > 0)
+ while (__map_.size() > 0)
{
- __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
- __base::__map_.pop_back();
+ __alloc_traits::deallocate(__a, __map_.back(), __block_size);
+ __map_.pop_back();
}
- __base::__start_ = 0;
+ __start_ = 0;
}
else
{
__maybe_remove_front_spare(/*__keep_one=*/false);
__maybe_remove_back_spare(/*__keep_one=*/false);
}
- __base::__map_.shrink_to_fit();
+ __map_.shrink_to_fit();
}
template <class _Tp, class _Allocator>
@@ -1859,8 +1203,8 @@ 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);
+ size_type __p = __start_ + __i;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1868,8 +1212,8 @@ 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);
+ size_type __p = __start_ + __i;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1877,10 +1221,10 @@ inline
typename deque<_Tp, _Allocator>::reference
deque<_Tp, _Allocator>::at(size_type __i)
{
- if (__i >= __base::size())
+ if (__i >= 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);
+ size_type __p = __start_ + __i;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1888,10 +1232,10 @@ inline
typename deque<_Tp, _Allocator>::const_reference
deque<_Tp, _Allocator>::at(size_type __i) const
{
- if (__i >= __base::size())
+ if (__i >= 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);
+ size_type __p = __start_ + __i;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1899,8 +1243,8 @@ 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);
+ return *(*(__map_.begin() + __start_ / __block_size)
+ + __start_ % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1908,8 +1252,8 @@ 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);
+ return *(*(__map_.begin() + __start_ / __block_size)
+ + __start_ % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1917,8 +1261,8 @@ 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);
+ size_type __p = size() + __start_ - 1;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
@@ -1926,33 +1270,33 @@ 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);
+ size_type __p = size() + __start_ - 1;
+ return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
}
template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::push_back(const value_type& __v)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
if (__back_spare() == 0)
__add_back_capacity();
// __back_spare() >= 1
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
+ ++__size();
}
template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::push_front(const value_type& __v)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
if (__front_spare() == 0)
__add_front_capacity();
// __front_spare() >= 1
- __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
- --__base::__start_;
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
+ --__start_;
+ ++__size();
}
#ifndef _LIBCPP_CXX03_LANG
@@ -1960,12 +1304,12 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::push_back(value_type&& __v)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
if (__back_spare() == 0)
__add_back_capacity();
// __back_spare() >= 1
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
+ ++__size();
}
template <class _Tp, class _Allocator>
@@ -1977,15 +1321,15 @@ void
#endif
deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
if (__back_spare() == 0)
__add_back_capacity();
// __back_spare() >= 1
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()),
_VSTD::forward<_Args>(__args)...);
- ++__base::size();
+ ++__size();
#if _LIBCPP_STD_VER > 14
- return *--__base::end();
+ return *--end();
#endif
}
@@ -1993,13 +1337,13 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::push_front(value_type&& __v)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __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();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
+ --__start_;
+ ++__size();
}
@@ -2012,15 +1356,15 @@ void
#endif
deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __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();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
+ --__start_;
+ ++__size();
#if _LIBCPP_STD_VER > 14
- return *__base::begin();
+ return *begin();
#endif
}
@@ -2028,9 +1372,9 @@ 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();
+ size_type __pos = __p - begin();
+ size_type __to_end = size() - __pos;
+ allocator_type& __a = __alloc();
if (__pos < __to_end)
{ // insert by shifting things backward
if (__front_spare() == 0)
@@ -2038,17 +1382,17 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
// __front_spare() >= 1
if (__pos == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
- --__base::__start_;
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
+ --__start_;
+ ++__size();
}
else
{
- iterator __b = __base::begin();
+ iterator __b = begin();
iterator __bm1 = _VSTD::prev(__b);
__alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
- --__base::__start_;
- ++__base::size();
+ --__start_;
+ ++__size();
if (__pos > 1)
__b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
*__b = _VSTD::move(__v);
@@ -2059,24 +1403,24 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
if (__back_spare() == 0)
__add_back_capacity();
// __back_capacity >= 1
- size_type __de = __base::size() - __pos;
+ size_type __de = size() - __pos;
if (__de == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
+ ++__size();
}
else
{
- iterator __e = __base::end();
+ iterator __e = end();
iterator __em1 = _VSTD::prev(__e);
__alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
- ++__base::size();
+ ++__size();
if (__de > 1)
__e = _VSTD::move_backward(__e - __de, __em1, __e);
*--__e = _VSTD::move(__v);
}
}
- return __base::begin() + __pos;
+ return begin() + __pos;
}
template <class _Tp, class _Allocator>
@@ -2084,9 +1428,9 @@ 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();
+ size_type __pos = __p - begin();
+ size_type __to_end = size() - __pos;
+ allocator_type& __a = __alloc();
if (__pos < __to_end)
{ // insert by shifting things backward
if (__front_spare() == 0)
@@ -2094,18 +1438,18 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
// __front_spare() >= 1
if (__pos == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
- --__base::__start_;
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
+ --__start_;
+ ++__size();
}
else
{
- __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
- iterator __b = __base::begin();
+ __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
+ iterator __b = begin();
iterator __bm1 = _VSTD::prev(__b);
__alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
- --__base::__start_;
- ++__base::size();
+ --__start_;
+ ++__size();
if (__pos > 1)
__b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
*__b = _VSTD::move(__tmp.get());
@@ -2116,25 +1460,25 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
if (__back_spare() == 0)
__add_back_capacity();
// __back_capacity >= 1
- size_type __de = __base::size() - __pos;
+ size_type __de = size() - __pos;
if (__de == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::forward<_Args>(__args)...);
+ ++__size();
}
else
{
- __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
- iterator __e = __base::end();
+ __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
+ iterator __e = end();
iterator __em1 = _VSTD::prev(__e);
__alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
- ++__base::size();
+ ++__size();
if (__de > 1)
__e = _VSTD::move_backward(__e - __de, __em1, __e);
*--__e = _VSTD::move(__tmp.get());
}
}
- return __base::begin() + __pos;
+ return begin() + __pos;
}
#endif // _LIBCPP_CXX03_LANG
@@ -2144,9 +1488,9 @@ 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();
+ size_type __pos = __p - begin();
+ size_type __to_end = size() - __pos;
+ allocator_type& __a = __alloc();
if (__pos < __to_end)
{ // insert by shifting things backward
if (__front_spare() == 0)
@@ -2154,20 +1498,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
// __front_spare() >= 1
if (__pos == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
- --__base::__start_;
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
+ --__start_;
+ ++__size();
}
else
{
const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
- iterator __b = __base::begin();
+ iterator __b = 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();
+ --__start_;
+ ++__size();
if (__pos > 1)
__b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);
*__b = *__vt;
@@ -2178,46 +1522,46 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
if (__back_spare() == 0)
__add_back_capacity();
// __back_capacity >= 1
- size_type __de = __base::size() - __pos;
+ size_type __de = size() - __pos;
if (__de == 0)
{
- __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
- ++__base::size();
+ __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
+ ++__size();
}
else
{
const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
- iterator __e = __base::end();
+ iterator __e = 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();
+ ++__size();
if (__de > 1)
__e = __move_backward_and_check(__e - __de, __em1, __e, __vt);
*--__e = *__vt;
}
}
- return __base::begin() + __pos;
+ return 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();
+ size_type __pos = __p - begin();
+ size_type __to_end = __size() - __pos;
+ allocator_type& __a = __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 __old_begin = begin();
iterator __i = __old_begin;
if (__n > __pos)
{
- for (size_type __m = __n - __pos; __m; --__m, --__base::__start_, ++__base::size())
+ for (size_type __m = __n - __pos; __m; --__m, --__start_, ++__size())
__alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);
__n = __pos;
}
@@ -2237,12 +1581,12 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
if (__n > __back_capacity)
__add_back_capacity(__n - __back_capacity);
// __n <= __back_capacity
- iterator __old_end = __base::end();
+ iterator __old_end = end();
iterator __i = __old_end;
- size_type __de = __base::size() - __pos;
+ size_type __de = size() - __pos;
if (__n > __de)
{
- for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__base::size())
+ for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__size())
__alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
__n = __de;
}
@@ -2256,7 +1600,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
_VSTD::fill_n(__old_end - __n, __n, *__vt);
}
}
- return __base::begin() + __pos;
+ return begin() + __pos;
}
template <class _Tp, class _Allocator>
@@ -2265,7 +1609,7 @@ typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)
{
- __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
+ __split_buffer<value_type, allocator_type&> __buf(__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()));
@@ -2278,7 +1622,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _Forwar
typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
{
size_type __n = _VSTD::distance(__f, __l);
- __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
+ __split_buffer<value_type, allocator_type&> __buf(__n, 0, __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()));
@@ -2291,21 +1635,21 @@ 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();
+ size_type __pos = __p - begin();
+ size_type __to_end = size() - __pos;
+ allocator_type& __a = __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 __old_begin = 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())
+ for (_BiIter __j = __m; __j != __f; --__start_, ++__size())
__alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);
__n = __pos;
}
@@ -2315,8 +1659,8 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
for (iterator __j = __obn; __j != __old_begin;)
{
__alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));
- --__base::__start_;
- ++__base::size();
+ --__start_;
+ ++__size();
}
if (__n < __pos)
__old_begin = _VSTD::move(__obn, __old_begin + __pos, __old_begin);
@@ -2329,28 +1673,28 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
if (__n > __back_capacity)
__add_back_capacity(__n - __back_capacity);
// __n <= __back_capacity
- iterator __old_end = __base::end();
+ iterator __old_end = end();
iterator __i = __old_end;
_BiIter __m = __l;
- size_type __de = __base::size() - __pos;
+ size_type __de = 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())
+ for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__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())
+ for (iterator __j = __oen; __j != __old_end; ++__i, (void) ++__j, ++__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;
+ return begin() + __pos;
}
template <class _Tp, class _Allocator>
@@ -2374,12 +1718,12 @@ 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();
+ allocator_type& __a = __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)) {
+ for (__deque_block_range __br : __deque_range(end(), 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);
@@ -2391,12 +1735,12 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__append(size_type __n)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __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)) {
+ for (__deque_block_range __br : __deque_range(end(), end() + __n)) {
_ConstructTransaction __tx(this, __br);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
__alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
@@ -2408,12 +1752,12 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __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)) {
+ for (__deque_block_range __br : __deque_range(end(), end() + __n)) {
_ConstructTransaction __tx(this, __br);
for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
__alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
@@ -2428,57 +1772,57 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__add_front_capacity()
{
- allocator_type& __a = __base::__alloc();
- if (__back_spare() >= __base::__block_size)
+ allocator_type& __a = __alloc();
+ if (__back_spare() >= __block_size)
{
- __base::__start_ += __base::__block_size;
- pointer __pt = __base::__map_.back();
- __base::__map_.pop_back();
- __base::__map_.push_front(__pt);
+ __start_ += __block_size;
+ pointer __pt = __map_.back();
+ __map_.pop_back();
+ __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())
+ // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer
+ else if (__map_.size() < __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));
+ if (__map_.__front_spare() > 0)
+ __map_.push_front(__alloc_traits::allocate(__a, __block_size));
else
{
- __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ __map_.push_back(__alloc_traits::allocate(__a, __block_size));
// Done allocating, reorder capacity
- pointer __pt = __base::__map_.back();
- __base::__map_.pop_back();
- __base::__map_.push_front(__pt);
+ pointer __pt = __map_.back();
+ __map_.pop_back();
+ __map_.push_front(__pt);
}
- __base::__start_ = __base::__map_.size() == 1 ?
- __base::__block_size / 2 :
- __base::__start_ + __base::__block_size;
+ __start_ = __map_.size() == 1 ?
+ __block_size / 2 :
+ __start_ + __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());
+ __split_buffer<pointer, __pointer_allocator&>
+ __buf(std::max<size_type>(2 * __map_.capacity(), 1),
+ 0, __map_.__alloc());
typedef __allocator_destructor<_Allocator> _Dp;
unique_ptr<pointer, _Dp> __hold(
- __alloc_traits::allocate(__a, __base::__block_size),
- _Dp(__a, __base::__block_size));
+ __alloc_traits::allocate(__a, __block_size),
+ _Dp(__a, __block_size));
__buf.push_back(__hold.get());
__hold.release();
- for (typename __base::__map_pointer __i = __base::__map_.begin();
- __i != __base::__map_.end(); ++__i)
+ for (__map_pointer __i = __map_.begin();
+ __i != __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;
+ _VSTD::swap(__map_.__first_, __buf.__first_);
+ _VSTD::swap(__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__map_.__end_, __buf.__end_);
+ _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
+ __start_ = __map_.size() == 1 ?
+ __block_size / 2 :
+ __start_ + __block_size;
}
}
@@ -2488,82 +1832,82 @@ 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());
+ allocator_type& __a = __alloc();
+ size_type __nb = __recommend_blocks(__n + __map_.empty());
// Number of unused blocks at back:
- size_type __back_capacity = __back_spare() / __base::__block_size;
+ size_type __back_capacity = __back_spare() / __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;
+ __start_ += __block_size * __back_capacity;
for (; __back_capacity > 0; --__back_capacity)
{
- pointer __pt = __base::__map_.back();
- __base::__map_.pop_back();
- __base::__map_.push_front(__pt);
+ pointer __pt = __map_.back();
+ __map_.pop_back();
+ __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())
+ else if (__nb <= __map_.capacity() - __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))
+ for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1))
{
- if (__base::__map_.__front_spare() == 0)
+ if (__map_.__front_spare() == 0)
break;
- __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ __map_.push_front(__alloc_traits::allocate(__a, __block_size));
}
for (; __nb > 0; --__nb, ++__back_capacity)
- __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ __map_.push_back(__alloc_traits::allocate(__a, __block_size));
// Done allocating, reorder capacity
- __base::__start_ += __back_capacity * __base::__block_size;
+ __start_ += __back_capacity * __block_size;
for (; __back_capacity > 0; --__back_capacity)
{
- pointer __pt = __base::__map_.back();
- __base::__map_.pop_back();
- __base::__map_.push_front(__pt);
+ pointer __pt = __map_.back();
+ __map_.pop_back();
+ __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());
+ size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();
+ __split_buffer<pointer, __pointer_allocator&>
+ __buf(std::max<size_type>(2* __map_.capacity(),
+ __nb + __map_.size()),
+ 0, __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));
+ __buf.push_back(__alloc_traits::allocate(__a, __block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
- for (typename __base::__map_pointer __i = __buf.begin();
+ for (__map_pointer __i = __buf.begin();
__i != __buf.end(); ++__i)
- __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+ __alloc_traits::deallocate(__a, *__i, __block_size);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
for (; __back_capacity > 0; --__back_capacity)
{
- __buf.push_back(__base::__map_.back());
- __base::__map_.pop_back();
+ __buf.push_back(__map_.back());
+ __map_.pop_back();
}
- for (typename __base::__map_pointer __i = __base::__map_.begin();
- __i != __base::__map_.end(); ++__i)
+ for (__map_pointer __i = __map_.begin();
+ __i != __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;
+ _VSTD::swap(__map_.__first_, __buf.__first_);
+ _VSTD::swap(__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__map_.__end_, __buf.__end_);
+ _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
+ __start_ += __ds;
}
}
@@ -2573,52 +1917,52 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__add_back_capacity()
{
- allocator_type& __a = __base::__alloc();
- if (__front_spare() >= __base::__block_size)
+ allocator_type& __a = __alloc();
+ if (__front_spare() >= __block_size)
{
- __base::__start_ -= __base::__block_size;
- pointer __pt = __base::__map_.front();
- __base::__map_.pop_front();
- __base::__map_.push_back(__pt);
+ __start_ -= __block_size;
+ pointer __pt = __map_.front();
+ __map_.pop_front();
+ __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())
+ else if (__map_.size() < __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));
+ if (__map_.__back_spare() != 0)
+ __map_.push_back(__alloc_traits::allocate(__a, __block_size));
else
{
- __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+ __map_.push_front(__alloc_traits::allocate(__a, __block_size));
// Done allocating, reorder capacity
- pointer __pt = __base::__map_.front();
- __base::__map_.pop_front();
- __base::__map_.push_back(__pt);
+ pointer __pt = __map_.front();
+ __map_.pop_front();
+ __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());
+ __split_buffer<pointer, __pointer_allocator&>
+ __buf(std::max<size_type>(2* __map_.capacity(), 1),
+ __map_.size(),
+ __map_.__alloc());
typedef __allocator_destructor<_Allocator> _Dp;
unique_ptr<pointer, _Dp> __hold(
- __alloc_traits::allocate(__a, __base::__block_size),
- _Dp(__a, __base::__block_size));
+ __alloc_traits::allocate(__a, __block_size),
+ _Dp(__a, __block_size));
__buf.push_back(__hold.get());
__hold.release();
- for (typename __base::__map_pointer __i = __base::__map_.end();
- __i != __base::__map_.begin();)
+ for (__map_pointer __i = __map_.end();
+ __i != __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());
+ _VSTD::swap(__map_.__first_, __buf.__first_);
+ _VSTD::swap(__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__map_.__end_, __buf.__end_);
+ _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
}
}
@@ -2628,84 +1972,84 @@ 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());
+ allocator_type& __a = __alloc();
+ size_type __nb = __recommend_blocks(__n + __map_.empty());
// Number of unused blocks at front:
- size_type __front_capacity = __front_spare() / __base::__block_size;
+ size_type __front_capacity = __front_spare() / __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;
+ __start_ -= __block_size * __front_capacity;
for (; __front_capacity > 0; --__front_capacity)
{
- pointer __pt = __base::__map_.front();
- __base::__map_.pop_front();
- __base::__map_.push_back(__pt);
+ pointer __pt = __map_.front();
+ __map_.pop_front();
+ __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())
+ else if (__nb <= __map_.capacity() - __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)
+ if (__map_.__back_spare() == 0)
break;
- __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+ __map_.push_back(__alloc_traits::allocate(__a, __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));
+ for (; __nb > 0; --__nb, ++__front_capacity, __start_ +=
+ __block_size - (__map_.size() == 1))
+ __map_.push_front(__alloc_traits::allocate(__a, __block_size));
// Done allocating, reorder capacity
- __base::__start_ -= __base::__block_size * __front_capacity;
+ __start_ -= __block_size * __front_capacity;
for (; __front_capacity > 0; --__front_capacity)
{
- pointer __pt = __base::__map_.front();
- __base::__map_.pop_front();
- __base::__map_.push_back(__pt);
+ pointer __pt = __map_.front();
+ __map_.pop_front();
+ __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());
+ size_type __ds = __front_capacity * __block_size;
+ __split_buffer<pointer, __pointer_allocator&>
+ __buf(std::max<size_type>(2* __map_.capacity(),
+ __nb + __map_.size()),
+ __map_.size() - __front_capacity,
+ __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));
+ __buf.push_back(__alloc_traits::allocate(__a, __block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
- for (typename __base::__map_pointer __i = __buf.begin();
+ for (__map_pointer __i = __buf.begin();
__i != __buf.end(); ++__i)
- __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+ __alloc_traits::deallocate(__a, *__i, __block_size);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
for (; __front_capacity > 0; --__front_capacity)
{
- __buf.push_back(__base::__map_.front());
- __base::__map_.pop_front();
+ __buf.push_back(__map_.front());
+ __map_.pop_front();
}
- for (typename __base::__map_pointer __i = __base::__map_.end();
- __i != __base::__map_.begin();)
+ for (__map_pointer __i = __map_.end();
+ __i != __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;
+ _VSTD::swap(__map_.__first_, __buf.__first_);
+ _VSTD::swap(__map_.__begin_, __buf.__begin_);
+ _VSTD::swap(__map_.__end_, __buf.__end_);
+ _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
+ __start_ -= __ds;
}
}
@@ -2713,12 +2057,12 @@ 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_;
+ allocator_type& __a = __alloc();
+ __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
+ __start_ / __block_size) +
+ __start_ % __block_size));
+ --__size();
+ ++__start_;
__maybe_remove_front_spare();
}
@@ -2727,12 +2071,12 @@ 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();
+ allocator_type& __a = __alloc();
+ size_type __p = size() + __start_ - 1;
+ __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
+ __p / __block_size) +
+ __p % __block_size));
+ --__size();
__maybe_remove_back_spare();
}
@@ -2750,7 +2094,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __
while (__n > 0)
{
pointer __fb = __f.__ptr_;
- pointer __fe = *__f.__m_iter_ + __base::__block_size;
+ pointer __fe = *__f.__m_iter_ + __block_size;
difference_type __bs = __fe - __fb;
if (__bs > __n)
{
@@ -2804,15 +2148,15 @@ void
deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
iterator __r, const_pointer& __vt)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
// as if
- // for (; __f != __l; ++__r, ++__f, ++__base::size())
+ // for (; __f != __l; ++__r, ++__f, ++__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;
+ pointer __fe = *__f.__m_iter_ + __block_size;
difference_type __bs = __fe - __fb;
if (__bs > __n)
{
@@ -2821,7 +2165,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
}
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())
+ for (; __fb != __fe; ++__fb, ++__r, ++__size())
__alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
__n -= __bs;
__f += __bs;
@@ -2835,13 +2179,13 @@ void
deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,
iterator __r, const_pointer& __vt)
{
- allocator_type& __a = __base::__alloc();
+ allocator_type& __a = __alloc();
// as if
// for (iterator __j = __l; __j != __f;)
// {
// __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));
- // --__base::__start_;
- // ++__base::size();
+ // --__start_;
+ // ++__size();
// }
difference_type __n = __l - __f;
while (__n > 0)
@@ -2860,8 +2204,8 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat
while (__le != __lb)
{
__alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
- --__base::__start_;
- ++__base::size();
+ --__start_;
+ ++__size();
}
__n -= __bs;
__l -= __bs - 1;
@@ -2872,26 +2216,26 @@ template <class _Tp, class _Allocator>
typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::erase(const_iterator __f)
{
- iterator __b = __base::begin();
+ iterator __b = 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)
+ allocator_type& __a = __alloc();
+ if (static_cast<size_t>(__pos) <= (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_;
+ --__size();
+ ++__start_;
__maybe_remove_front_spare();
}
else
{ // erase from back
- iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p);
+ iterator __i = _VSTD::move(_VSTD::next(__p), end(), __p);
__alloc_traits::destroy(__a, _VSTD::addressof(*__i));
- --__base::size();
+ --__size();
__maybe_remove_back_spare();
}
- return __base::begin() + __pos;
+ return begin() + __pos;
}
template <class _Tp, class _Allocator>
@@ -2899,49 +2243,49 @@ typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
{
difference_type __n = __l - __f;
- iterator __b = __base::begin();
+ iterator __b = 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)
+ allocator_type& __a = __alloc();
+ if (static_cast<size_t>(__pos) <= (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;
+ __size() -= __n;
+ __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)
+ iterator __i = _VSTD::move(__p + __n, end(), __p);
+ for (iterator __e = end(); __i != __e; ++__i)
__alloc_traits::destroy(__a, _VSTD::addressof(*__i));
- __base::size() -= __n;
+ __size() -= __n;
while (__maybe_remove_back_spare()) {
}
}
}
- return __base::begin() + __pos;
+ return begin() + __pos;
}
template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
{
- iterator __e = __base::end();
+ iterator __e = end();
difference_type __n = __e - __f;
if (__n > 0)
{
- allocator_type& __a = __base::__alloc();
- iterator __b = __base::begin();
+ allocator_type& __a = __alloc();
+ iterator __b = begin();
difference_type __pos = __f - __b;
for (iterator __p = __b + __pos; __p != __e; ++__p)
__alloc_traits::destroy(__a, _VSTD::addressof(*__p));
- __base::size() -= __n;
+ __size() -= __n;
while (__maybe_remove_back_spare()) {
}
}
@@ -2958,7 +2302,10 @@ deque<_Tp, _Allocator>::swap(deque& __c)
__is_nothrow_swappable<allocator_type>::value)
#endif
{
- __base::swap(__c);
+ __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>
@@ -2966,11 +2313,28 @@ inline
void
deque<_Tp, _Allocator>::clear() _NOEXCEPT
{
- __base::clear();
+ 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>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -2979,7 +2343,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -2987,7 +2351,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -2995,7 +2359,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -3003,7 +2367,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -3011,7 +2375,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
{
@@ -3019,7 +2383,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
void
swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
@@ -3029,7 +2393,7 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
+inline _LIBCPP_HIDE_FROM_ABI 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());
@@ -3037,7 +2401,7 @@ erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
}
template <class _Tp, class _Allocator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
+inline _LIBCPP_HIDE_FROM_ABI 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());
@@ -3055,6 +2419,25 @@ inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _ValueT>
+using deque = std::deque<_ValueT, polymorphic_allocator<_ValueT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <atomic>
+# include <concepts>
+# include <functional>
+# include <iosfwd>
+# include <iterator>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_DEQUE
diff --git a/libcxx/include/errno.h b/libcxx/include/errno.h
index ea0559f0f5d1..7b02d2b47953 100644
--- a/libcxx/include/errno.h
+++ b/libcxx/include/errno.h
@@ -28,7 +28,9 @@ Macros:
# pragma GCC system_header
#endif
-#include_next <errno.h>
+#if __has_include_next(<errno.h>)
+# include_next <errno.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/exception b/libcxx/include/exception
index 7b514e5dca54..e0f42682b579 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -80,13 +80,21 @@ template <class E> void rethrow_if_nested(const E& e);
#include <__availability>
#include <__config>
#include <__memory/addressof.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_class.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_final.h>
+#include <__type_traits/is_polymorphic.h>
#include <cstddef>
#include <cstdlib>
-#include <type_traits>
#include <version>
+// <vcruntime_exception.h> defines its own std::exception and std::bad_exception types,
+// which we use in order to be ABI-compatible with other STLs on Windows.
#if defined(_LIBCPP_ABI_VCRUNTIME)
-#include <vcruntime_exception.h>
+# include <vcruntime_exception.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -96,24 +104,66 @@ template <class E> void rethrow_if_nested(const E& e);
namespace std // purposefully not using versioning namespace
{
-#if !defined(_LIBCPP_ABI_VCRUNTIME)
-class _LIBCPP_EXCEPTION_ABI exception
-{
+#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
+// The std::exception class was already included above, but we're explicit about this condition here for clarity.
+
+#elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+// However, <vcruntime_exception.h> does not define std::exception and std::bad_exception
+// when _HAS_EXCEPTIONS == 0.
+//
+// Since libc++ still wants to provide the std::exception hierarchy even when _HAS_EXCEPTIONS == 0
+// (after all those are simply types like any other), we define an ABI-compatible version
+// of the VCRuntime std::exception and std::bad_exception types in that mode.
+
+struct __std_exception_data {
+ char const* _What;
+ bool _DoFree;
+};
+
+class exception { // base of all library exceptions
public:
- _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
+ exception() _NOEXCEPT : __data_() {}
- virtual ~exception() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ explicit exception(char const* __message) _NOEXCEPT : __data_() {
+ __data_._What = __message;
+ __data_._DoFree = true;
+ }
+
+ exception(exception const&) _NOEXCEPT {}
+
+ exception& operator=(exception const&) _NOEXCEPT { return *this; }
+
+ virtual ~exception() _NOEXCEPT {}
+
+ virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : "Unknown exception"; }
+
+private:
+ __std_exception_data __data_;
};
-class _LIBCPP_EXCEPTION_ABI bad_exception
- : public exception
-{
+class bad_exception : public exception {
+public:
+ bad_exception() _NOEXCEPT : exception("bad exception") {}
+};
+
+#else // !defined(_LIBCPP_ABI_VCRUNTIME)
+// On all other platforms, we define our own std::exception and std::bad_exception types
+// regardless of whether exceptions are turned on as a language feature.
+
+class _LIBCPP_EXCEPTION_ABI exception {
public:
- _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
- virtual ~bad_exception() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ _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 {}
+ ~bad_exception() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
#endif // !_LIBCPP_ABI_VCRUNTIME
@@ -282,7 +332,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
#endif
template <class _Tp>
-_LIBCPP_NORETURN
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void
throw_with_nested(_Tp&& __t)
{
@@ -327,4 +377,8 @@ rethrow_if_nested(const _Ep&,
} // namespace std
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_EXCEPTION
diff --git a/libcxx/include/expected b/libcxx/include/expected
new file mode 100644
index 000000000000..486d0a21d087
--- /dev/null
+++ b/libcxx/include/expected
@@ -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_EXPECTED
+#define _LIBCPP_EXPECTED
+
+/*
+ Header <expected> synopsis
+
+namespace std {
+ // [expected.unexpected], class template unexpected
+ template<class E> class unexpected;
+
+ // [expected.bad], class template bad_expected_access
+ template<class E> class bad_expected_access;
+
+ // [expected.bad.void], specialization for void
+ template<> class bad_expected_access<void>;
+
+ // in-place construction of unexpected values
+ struct unexpect_t {
+ explicit unexpect_t() = default;
+ };
+ inline constexpr unexpect_t unexpect{};
+
+ // [expected.expected], class template expected
+ template<class T, class E> class expected;
+
+ // [expected.void], partial specialization of expected for void types
+ template<class T, class E> requires is_void_v<T> class expected<T, E>;
+}
+
+*/
+
+#include <__assert> // all public C++ headers provide the assertion handler
+#include <__config>
+#include <__expected/bad_expected_access.h>
+#include <__expected/expected.h>
+#include <__expected/unexpect.h>
+#include <__expected/unexpected.h>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif // _LIBCPP_EXPECTED
+
diff --git a/libcxx/include/experimental/__memory b/libcxx/include/experimental/__memory
index 749cf4c0c657..b36f31eebb7c 100644
--- a/libcxx/include/experimental/__memory
+++ b/libcxx/include/experimental/__memory
@@ -56,11 +56,11 @@ struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...>
= is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const bool __ic_second =
- conditional<
+ __conditional_t<
__ic_first,
false_type,
is_constructible<_Tp, _Args..., _Alloc>
- >::type::value;
+ >::value;
static_assert(__ic_first || __ic_second,
"Request for uses allocator construction is ill-formed");
diff --git a/libcxx/include/experimental/coroutine b/libcxx/include/experimental/coroutine
index 111073bb6d67..d9f368535024 100644
--- a/libcxx/include/experimental/coroutine
+++ b/libcxx/include/experimental/coroutine
@@ -50,10 +50,28 @@ template <class P> struct hash<coroutine_handle<P>>;
#include <__functional/operations.h>
#include <cstddef>
#include <experimental/__config>
-#include <memory> // for hash<T*>
#include <new>
#include <type_traits>
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <climits>
+# include <cmath>
+# include <compare>
+# include <concepts>
+# include <ctime>
+# include <initializer_list>
+# include <iosfwd>
+# include <iterator>
+# include <memory>
+# include <ratio>
+# include <stdexcept>
+# include <tuple>
+# include <typeinfo>
+# include <utility>
+# include <variant>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -66,8 +84,7 @@ 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>
+struct __coroutine_traits_sfinae<_Tp, __void_t<typename _Tp::promise_type> >
{
using promise_type = typename _Tp::promise_type;
};
@@ -241,7 +258,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
- typedef typename remove_cv<_Promise>::type _RawPromise;
+ typedef __remove_cv_t<_Promise> _RawPromise;
coroutine_handle __tmp;
__tmp.__handle_ = __builtin_coro_promise(
_VSTD::addressof(const_cast<_RawPromise&>(__promise)),
@@ -269,9 +286,9 @@ public:
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
_LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() const _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void resume() const _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy() const _NOEXCEPT {}
private:
_LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/experimental/deque b/libcxx/include/experimental/deque
index 3e3f9098a8fd..46962afbb795 100644
--- a/libcxx/include/experimental/deque
+++ b/libcxx/include/experimental/deque
@@ -40,9 +40,13 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _ValueT>
using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */
diff --git a/libcxx/include/experimental/forward_list b/libcxx/include/experimental/forward_list
index 4b102c554704..5d2686deb276 100644
--- a/libcxx/include/experimental/forward_list
+++ b/libcxx/include/experimental/forward_list
@@ -40,9 +40,13 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _ValueT>
using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */
diff --git a/libcxx/include/experimental/functional b/libcxx/include/experimental/functional
index 12440744ca50..cb9a5efac3f8 100644
--- a/libcxx/include/experimental/functional
+++ b/libcxx/include/experimental/functional
@@ -85,9 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER
# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER
#else
-# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
-# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
-# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
+# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
+# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
#endif
#if _LIBCPP_STD_VER > 11
@@ -132,24 +132,24 @@ class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
typedef _Key key_type;
const _Value __default_value_;
- std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
+ std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
- : __default_value_(__default), __table(__sz, __hf, __pred) {}
+ : __default_value_(__default), __table_(__sz, __hf, __pred) {}
_LIBCPP_INLINE_VISIBILITY
void insert(const key_type &__key, value_type __val)
{
- __table [__key] = __val; // Would skip_.insert (val) be better here?
+ __table_ [__key] = __val; // Would skip_.insert (val) be better here?
}
_LIBCPP_INLINE_VISIBILITY
value_type operator [](const key_type & __key) const
{
- auto __it = __table.find (__key);
- return __it == __table.end() ? __default_value_ : __it->second;
+ auto __it = __table_.find (__key);
+ return __it == __table_.end() ? __default_value_ : __it->second;
}
};
@@ -161,27 +161,27 @@ private:
typedef _Value value_type;
typedef _Key key_type;
- typedef typename make_unsigned<key_type>::type unsigned_key_type;
+ typedef __make_unsigned_t<key_type> unsigned_key_type;
typedef std::array<value_type, 256> skip_map;
- skip_map __table;
+ skip_map __table_;
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
{
- std::fill_n(__table.begin(), __table.size(), __default);
+ std::fill_n(__table_.begin(), __table_.size(), __default);
}
_LIBCPP_INLINE_VISIBILITY
void insert(key_type __key, value_type __val)
{
- __table[static_cast<unsigned_key_type>(__key)] = __val;
+ __table_[static_cast<unsigned_key_type>(__key)] = __val;
}
_LIBCPP_INLINE_VISIBILITY
value_type operator [](key_type __key) const
{
- return __table[static_cast<unsigned_key_type>(__key)];
+ return __table_[static_cast<unsigned_key_type>(__key)];
}
};
@@ -205,8 +205,8 @@ public:
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
- __skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
- __suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)}
+ __skip_{std::make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
+ __suffix_{std::make_shared<vector<difference_type>>(__pattern_length_ + 1)}
{
// build the skip table
for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
@@ -223,12 +223,12 @@ public:
typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
"Corpus and Pattern iterators must point to the same type");
- if (__f == __l ) return make_pair(__l, __l); // empty corpus
- if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
+ if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
+ if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
if ( __pattern_length_ > _VSTD::distance(__f, __l))
- return make_pair(__l, __l);
+ return std::make_pair(__l, __l);
// Do the search
return this->__search(__f, __l);
@@ -260,7 +260,7 @@ private:
__j--;
// We matched - we're done!
if ( __j == 0 )
- return make_pair(__cur, __cur + __pattern_length_);
+ return std::make_pair(__cur, __cur + __pattern_length_);
}
// Since we didn't match, figure out how far to skip forward
@@ -272,7 +272,7 @@ private:
__cur += __suffix[ __j ];
}
- return make_pair(__l, __l); // We didn't find anything
+ return std::make_pair(__l, __l); // We didn't find anything
}
@@ -373,12 +373,12 @@ public:
typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
"Corpus and Pattern iterators must point to the same type");
- if (__f == __l ) return make_pair(__l, __l); // empty corpus
- if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
+ if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
+ if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
if ( __pattern_length_ > _VSTD::distance(__f, __l))
- return make_pair(__l, __l);
+ return std::make_pair(__l, __l);
// Do the search
return this->__search(__f, __l);
@@ -407,12 +407,12 @@ private:
__j--;
// We matched - we're done!
if ( __j == 0 )
- return make_pair(__cur, __cur + __pattern_length_);
+ return std::make_pair(__cur, __cur + __pattern_length_);
}
__cur += __skip[__cur[__pattern_length_-1]];
}
- return make_pair(__l, __l);
+ return std::make_pair(__l, __l);
}
};
diff --git a/libcxx/include/experimental/iterator b/libcxx/include/experimental/iterator
index a92bca6a20fa..cf73b74e887e 100644
--- a/libcxx/include/experimental/iterator
+++ b/libcxx/include/experimental/iterator
@@ -54,6 +54,7 @@ namespace std {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__memory/addressof.h>
+#include <__type_traits/decay.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <experimental/__config>
@@ -82,19 +83,19 @@ public:
typedef void reference;
ostream_joiner(ostream_type& __os, _Delim&& __d)
- : __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
+ : __output_iter_(_VSTD::addressof(__os)), __delim_(_VSTD::move(__d)), __first_(true) {}
ostream_joiner(ostream_type& __os, const _Delim& __d)
- : __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
+ : __output_iter_(_VSTD::addressof(__os)), __delim_(__d), __first_(true) {}
template<typename _Tp>
ostream_joiner& operator=(const _Tp& __v)
{
- if (!__first)
- *__output_iter << __delim;
- __first = false;
- *__output_iter << __v;
+ if (!__first_)
+ *__output_iter_ << __delim_;
+ __first_ = false;
+ *__output_iter_ << __v;
return *this;
}
@@ -103,14 +104,14 @@ public:
ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
private:
- ostream_type* __output_iter;
- _Delim __delim;
- bool __first;
+ ostream_type* __output_iter_;
+ _Delim __delim_;
+ bool __first_;
};
template <class _CharT, class _Traits, class _Delim>
-ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
+_LIBCPP_HIDE_FROM_ABI ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
@@ -118,4 +119,8 @@ _LIBCPP_END_NAMESPACE_LFTS
#endif // _LIBCPP_STD_VER > 11
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
diff --git a/libcxx/include/experimental/list b/libcxx/include/experimental/list
index c8480575977e..06abe8702241 100644
--- a/libcxx/include/experimental/list
+++ b/libcxx/include/experimental/list
@@ -40,9 +40,13 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _ValueT>
using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_LIST */
diff --git a/libcxx/include/experimental/map b/libcxx/include/experimental/map
index 3dee7f703aeb..8ec94e4a5bc8 100644
--- a/libcxx/include/experimental/map
+++ b/libcxx/include/experimental/map
@@ -45,6 +45,8 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Key, class _Value, class _Compare = less<_Key>>
using map = _VSTD::map<_Key, _Value, _Compare,
polymorphic_allocator<pair<const _Key, _Value>>>;
@@ -53,6 +55,8 @@ template <class _Key, class _Value, class _Compare = less<_Key>>
using multimap = _VSTD::multimap<_Key, _Value, _Compare,
polymorphic_allocator<pair<const _Key, _Value>>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_MAP */
diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource
index f7b19aafd40f..f107f109203f 100644
--- a/libcxx/include/experimental/memory_resource
+++ b/libcxx/include/experimental/memory_resource
@@ -65,16 +65,16 @@ namespace pmr {
*/
#include <__assert> // all public C++ headers provide the assertion handler
-#include <__tuple>
+#include <__memory/allocator_traits.h>
#include <__utility/move.h>
#include <cstddef>
#include <cstdlib>
#include <experimental/__config>
#include <experimental/__memory>
#include <limits>
-#include <memory>
#include <new>
#include <stdexcept>
+#include <tuple>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -86,6 +86,12 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#define _LIBCPP_DEPCREATED_MEMORY_RESOURCE(name) \
+ _LIBCPP_DEPRECATED_("'std::experimental::pmr::" name \
+ "' is deprecated and will be removed in LLVM 18. Use 'std::pmr::" name "' instead.")
+
+#ifndef _LIBCPP_CXX03_LANG
+
// Round __s up to next multiple of __a.
inline _LIBCPP_INLINE_VISIBILITY
size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
@@ -95,7 +101,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
}
// 8.5, memory.resource
-class _LIBCPP_TYPE_VIS memory_resource
+class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("memory_resource") _LIBCPP_TYPE_VIS memory_resource
{
static const size_t __max_align = _LIBCPP_ALIGNOF(max_align_t);
@@ -123,37 +129,37 @@ private:
};
// 8.5.4, memory.resource.eq
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
bool operator==(memory_resource const & __lhs,
memory_resource const & __rhs) _NOEXCEPT
{
return &__lhs == &__rhs || __lhs.is_equal(__rhs);
}
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(memory_resource const & __lhs,
memory_resource const & __rhs) _NOEXCEPT
{
return !(__lhs == __rhs);
}
-_LIBCPP_FUNC_VIS
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("new_delete_resource()") _LIBCPP_FUNC_VIS
memory_resource * new_delete_resource() _NOEXCEPT;
-_LIBCPP_FUNC_VIS
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("null_memory_resource()") _LIBCPP_FUNC_VIS
memory_resource * null_memory_resource() _NOEXCEPT;
-_LIBCPP_FUNC_VIS
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("get_default_resource()") _LIBCPP_FUNC_VIS
memory_resource * get_default_resource() _NOEXCEPT;
-_LIBCPP_FUNC_VIS
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("set_default_resource()") _LIBCPP_FUNC_VIS
memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
// 8.6, memory.polymorphic.allocator.class
// 8.6.1, memory.polymorphic.allocator.overview
template <class _ValueType>
-class _LIBCPP_TEMPLATE_VIS polymorphic_allocator
+class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("polymorphic_allocator") _LIBCPP_TEMPLATE_VIS polymorphic_allocator
{
public:
typedef _ValueType value_type;
@@ -314,6 +320,7 @@ private:
// 8.6.4, memory.polymorphic.allocator.eq
template <class _Tp, class _Up>
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(const polymorphic_allocator&, const polymorphic_allocator&)")
inline _LIBCPP_INLINE_VISIBILITY
bool operator==(polymorphic_allocator<_Tp> const & __lhs,
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
@@ -322,6 +329,7 @@ bool operator==(polymorphic_allocator<_Tp> const & __lhs,
}
template <class _Tp, class _Up>
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(const polymorphic_allocator&, const polymorphic_allocator&)")
inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
@@ -331,6 +339,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
// 8.7, memory.resource.adaptor
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
// 8.7.1, memory.resource.adaptor.overview
template <class _CharAlloc>
class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp
@@ -379,7 +388,7 @@ public:
// 8.7.3, memory.resource.adaptor.mem
private:
- virtual void * do_allocate(size_t __bytes, size_t)
+ void * do_allocate(size_t __bytes, size_t) override
{
if (__bytes > __max_size())
__throw_bad_array_new_length();
@@ -387,7 +396,7 @@ private:
return __alloc_.allocate(__s);
}
- virtual void do_deallocate(void * __p, size_t __bytes, size_t)
+ void do_deallocate(void * __p, size_t __bytes, size_t) override
{
_LIBCPP_ASSERT(__bytes <= __max_size(),
"do_deallocate called for size which exceeds the maximum allocation size");
@@ -395,7 +404,7 @@ private:
__alloc_.deallocate((_ValueType*)__p, __s);
}
- virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT {
+ bool do_is_equal(memory_resource const & __other) const _NOEXCEPT override {
__resource_adaptor_imp const * __p
= dynamic_cast<__resource_adaptor_imp const *>(&__other);
return __p ? __alloc_ == __p->__alloc_ : false;
@@ -411,9 +420,24 @@ template <class _Alloc>
using resource_adaptor = __resource_adaptor_imp<
typename allocator_traits<_Alloc>::template rebind_alloc<char>
>;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_LFTS_PMR
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <climits>
+# include <concepts>
+# include <cstring>
+# include <ctime>
+# include <iterator>
+# include <memory>
+# include <ratio>
+# include <variant>
+#endif
+
#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */
diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const
index 432635668e4e..34e917da5154 100644
--- a/libcxx/include/experimental/propagate_const
+++ b/libcxx/include/experimental/propagate_const
@@ -109,6 +109,7 @@
#include <__assert> // all public C++ headers provide the assertion handler
#include <__functional/operations.h>
+#include <__fwd/hash.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/swap.h>
@@ -138,15 +139,15 @@ template <class _Tp>
class propagate_const
{
public:
- typedef remove_reference_t<decltype(*declval<_Tp&>())> element_type;
+ typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
static_assert(!is_array<_Tp>::value,
"Instantiation of propagate_const with an array type is ill-formed.");
static_assert(!is_reference<_Tp>::value,
"Instantiation of propagate_const with a reference type is ill-formed.");
- static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value),
+ static_assert(!(is_pointer<_Tp>::value && is_function<__remove_pointer_t<_Tp> >::value),
"Instantiation of propagate_const with a function-pointer type is ill-formed.");
- static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value),
+ static_assert(!(is_pointer<_Tp>::value && is_same<__remove_cv_t<__remove_pointer_t<_Tp> >, void>::value),
"Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
private:
diff --git a/libcxx/include/experimental/regex b/libcxx/include/experimental/regex
index 4dc2bbae4510..0c871f366dc8 100644
--- a/libcxx/include/experimental/regex
+++ b/libcxx/include/experimental/regex
@@ -48,18 +48,22 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _BiDirIter>
using match_results =
_VSTD::match_results<_BiDirIter,
polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;
-typedef match_results<const char*> cmatch;
-typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("cmatch") typedef match_results<const char*> cmatch;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("smatch") typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-typedef match_results<const wchar_t*> wcmatch;
-typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wcmatch") typedef match_results<const wchar_t*> wcmatch;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wsmatch") typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
#endif
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_REGEX */
diff --git a/libcxx/include/experimental/set b/libcxx/include/experimental/set
index e2e75e35448b..cd61e6449597 100644
--- a/libcxx/include/experimental/set
+++ b/libcxx/include/experimental/set
@@ -45,6 +45,8 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Value, class _Compare = less<_Value>>
using set = _VSTD::set<_Value, _Compare,
polymorphic_allocator<_Value>>;
@@ -53,6 +55,8 @@ template <class _Value, class _Compare = less<_Value>>
using multiset = _VSTD::multiset<_Value, _Compare,
polymorphic_allocator<_Value>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_SET */
diff --git a/libcxx/include/experimental/simd b/libcxx/include/experimental/simd
index f77ce59bb269..4ca67d212b23 100644
--- a/libcxx/include/experimental/simd
+++ b/libcxx/include/experimental/simd
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP_EXPERIMENTAL_SIMD
#define _LIBCPP_EXPERIMENTAL_SIMD
@@ -656,11 +657,6 @@ public:
#include <experimental/__config>
#include <tuple>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -720,12 +716,12 @@ public:
#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
-constexpr size_t __floor_pow_of_2(size_t __val) {
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __floor_pow_of_2(size_t __val) {
return ((__val - 1) & __val) == 0 ? __val
: __floor_pow_of_2((__val - 1) & __val);
}
-constexpr size_t __ceil_pow_of_2(size_t __val) {
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __ceil_pow_of_2(size_t __val) {
return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
}
@@ -913,25 +909,27 @@ public:
};
template <class _To, class _From>
-constexpr decltype(_To{std::declval<_From>()}, true)
+_LIBCPP_HIDE_FROM_ABI constexpr decltype(_To{std::declval<_From>()}, true)
__is_non_narrowing_convertible_impl(_From) {
return true;
}
template <class _To>
-constexpr bool __is_non_narrowing_convertible_impl(...) {
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_non_narrowing_convertible_impl(...) {
return false;
}
template <class _From, class _To>
+_LIBCPP_HIDE_FROM_ABI
constexpr typename std::enable_if<std::is_arithmetic<_To>::value &&
std::is_arithmetic<_From>::value,
bool>::type
__is_non_narrowing_arithmetic_convertible() {
- return __is_non_narrowing_convertible_impl<_To>(_From{});
+ return experimental::__is_non_narrowing_convertible_impl<_To>(_From{});
}
template <class _From, class _To>
+_LIBCPP_HIDE_FROM_ABI
constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value &&
std::is_arithmetic<_From>::value),
bool>::type
@@ -940,13 +938,13 @@ __is_non_narrowing_arithmetic_convertible() {
}
template <class _Tp>
-constexpr _Tp __variadic_sum() {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum() {
return _Tp{};
}
template <class _Tp, class _Up, class... _Args>
-constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
- return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...);
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
+ return static_cast<_Tp>(__first) + experimental::__variadic_sum<_Tp>(__rest...);
}
template <class _Tp>
@@ -955,7 +953,7 @@ struct __nodeduce {
};
template <class _Tp>
-constexpr bool __vectorizable() {
+_LIBCPP_HIDE_FROM_ABI constexpr bool __vectorizable() {
return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
!std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
}
@@ -1060,7 +1058,7 @@ struct simd_size<_Tp, __simd_abi<__kind, _Np>>
: std::integral_constant<size_t, _Np> {
static_assert(
std::is_arithmetic<_Tp>::value &&
- !std::is_same<typename std::remove_const<_Tp>::type, bool>::value,
+ !std::is_same<__remove_const_t<_Tp>, bool>::value,
"Element type should be vectorizable");
};
@@ -1123,13 +1121,13 @@ struct __simd_cast_traits<simd<_Tp, _NewAbi>> {
};
template <class _Tp, class _Up, class _Abi>
-auto simd_cast(const simd<_Up, _Abi>& __v)
+_LIBCPP_HIDE_FROM_ABI auto simd_cast(const simd<_Up, _Abi>& __v)
-> decltype(__simd_cast_traits<_Tp>::__apply(__v)) {
return __simd_cast_traits<_Tp>::__apply(__v);
}
template <class _Tp, class _Up, class _Abi>
-auto static_simd_cast(const simd<_Up, _Abi>& __v)
+_LIBCPP_HIDE_FROM_ABI auto static_simd_cast(const simd<_Up, _Abi>& __v)
-> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) {
return __static_simd_cast_traits<_Tp>::__apply(__v);
}
@@ -1172,12 +1170,12 @@ array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /
split(const simd_mask<typename _SimdType::value_type, _Abi>&);
template <class _Tp, class... _Abis>
-simd<_Tp, abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
+simd<_Tp, abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>>
concat(const simd<_Tp, _Abis>&...);
template <class _Tp, class... _Abis>
simd_mask<_Tp,
- abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
+ abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>>
concat(const simd_mask<_Tp, _Abis>&...);
// reductions [simd.mask.reductions]
@@ -1302,7 +1300,7 @@ class const_where_expression {
public:
const_where_expression(const const_where_expression&) = delete;
const_where_expression& operator=(const const_where_expression&) = delete;
- typename remove_const<_Tp>::type operator-() const&&;
+ __remove_const_t<_Tp> operator-() const&&;
template <class _Up, class _Flags>
void copy_to(_Up*, _Flags) const&&;
};
@@ -1369,8 +1367,8 @@ private:
__is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) ||
(!std::is_arithmetic<_Up>::value &&
std::is_convertible<_Up, _Tp>::value) ||
- std::is_same<typename std::remove_const<_Up>::type, int>::value ||
- (std::is_same<typename std::remove_const<_Up>::type,
+ std::is_same<__remove_const_t<_Up>, int>::value ||
+ (std::is_same<__remove_const_t<_Up>,
unsigned int>::value &&
std::is_unsigned<_Tp>::value);
}
@@ -1381,7 +1379,7 @@ private:
std::integral_constant<size_t, __indicies>())...),
bool())
__can_generate(std::index_sequence<__indicies...>) {
- return !__variadic_sum<bool>(
+ return !experimental::__variadic_sum<bool>(
!__can_broadcast<decltype(std::declval<_Generator>()(
std::integral_constant<size_t, __indicies>()))>()...);
}
@@ -1579,4 +1577,9 @@ _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <functional>
+#endif
+
#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
diff --git a/libcxx/include/experimental/string b/libcxx/include/experimental/string
index c795d685d735..4edbf98b5f73 100644
--- a/libcxx/include/experimental/string
+++ b/libcxx/include/experimental/string
@@ -49,17 +49,25 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+
template <class _CharT, class _Traits = char_traits<_CharT>>
using basic_string =
_VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
-typedef basic_string<char> string;
-typedef basic_string<char16_t> u16string;
-typedef basic_string<char32_t> u32string;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("string") typedef basic_string<char> string;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u16string") typedef basic_string<char16_t> u16string;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u32string") typedef basic_string<char32_t> u32string;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-typedef basic_string<wchar_t> wstring;
+_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wstring") typedef basic_string<wchar_t> wstring;
#endif
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_STRING */
diff --git a/libcxx/include/experimental/unordered_map b/libcxx/include/experimental/unordered_map
index 636d31bdc557..d2801822a56f 100644
--- a/libcxx/include/experimental/unordered_map
+++ b/libcxx/include/experimental/unordered_map
@@ -45,20 +45,14 @@ namespace pmr {
#include <experimental/memory_resource>
#include <unordered_map>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <array>
-# include <bit>
-# include <functional>
-# include <vector>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Key, class _Value,
class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,
@@ -69,6 +63,16 @@ template <class _Key, class _Value,
using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,
polymorphic_allocator<pair<const _Key, _Value>>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <array>
+# include <bit>
+# include <functional>
+# include <vector>
+#endif
+
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */
diff --git a/libcxx/include/experimental/unordered_set b/libcxx/include/experimental/unordered_set
index 509f3ec1044e..493e3a09ed10 100644
--- a/libcxx/include/experimental/unordered_set
+++ b/libcxx/include/experimental/unordered_set
@@ -45,6 +45,8 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Value,
class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,
@@ -55,6 +57,8 @@ template <class _Value,
using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,
polymorphic_allocator<_Value>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */
diff --git a/libcxx/include/experimental/vector b/libcxx/include/experimental/vector
index 97c51c830c4a..2e9d77e41af2 100644
--- a/libcxx/include/experimental/vector
+++ b/libcxx/include/experimental/vector
@@ -40,9 +40,13 @@ namespace pmr {
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _ValueT>
using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */
diff --git a/libcxx/include/ext/__hash b/libcxx/include/ext/__hash
index 0e6c2cc05b52..880d0eebef49 100644
--- a/libcxx/include/ext/__hash
+++ b/libcxx/include/ext/__hash
@@ -14,6 +14,7 @@
#include <__config>
#include <cstring>
+#include <stddef.h>
#include <string>
namespace __gnu_cxx {
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index a581d5c550c4..3ad4b166865a 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -210,10 +210,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <stdexcept>
#include <type_traits>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-#endif
-
#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
@@ -382,7 +378,7 @@ public:
typedef std::pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef value_type& reference;
- typedef typename std::__rebind_pointer<typename _HashIterator::pointer, value_type>::type
+ typedef std::__rebind_pointer_t<typename _HashIterator::pointer, value_type>
pointer;
_LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
@@ -427,7 +423,7 @@ public:
typedef std::pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef const value_type& reference;
- typedef typename std::__rebind_pointer<typename _HashIterator::pointer, const value_type>::type
+ typedef std::__rebind_pointer_t<typename _HashIterator::pointer, const value_type>
pointer;
_LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
@@ -487,8 +483,7 @@ private:
typedef std::pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
- typedef typename std::__rebind_alloc_helper<
- std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
+ typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type;
typedef std::__hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -714,7 +709,7 @@ swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
@@ -761,7 +756,7 @@ private:
typedef std::pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
- typedef typename std::__rebind_alloc_helper<std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
+ typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type;
typedef std::__hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -954,7 +949,7 @@ swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
@@ -987,4 +982,9 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
} // namespace __gnu_cxx
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_HASH_MAP
diff --git a/libcxx/include/ext/hash_set b/libcxx/include/ext/hash_set
index 5823b5fb9476..dc8b78645384 100644
--- a/libcxx/include/ext/hash_set
+++ b/libcxx/include/ext/hash_set
@@ -199,10 +199,6 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <ext/__hash>
#include <functional>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-#endif
-
#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
@@ -412,7 +408,7 @@ swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
@@ -633,7 +629,7 @@ swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
@@ -666,4 +662,9 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
} // namespace __gnu_cxx
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_HASH_SET
diff --git a/libcxx/include/fenv.h b/libcxx/include/fenv.h
index a9ba6800245b..15e41568cbf7 100644
--- a/libcxx/include/fenv.h
+++ b/libcxx/include/fenv.h
@@ -56,7 +56,9 @@ int feupdateenv(const fenv_t* envp);
# pragma GCC system_header
#endif
-#include_next <fenv.h>
+#if __has_include_next(<fenv.h>)
+# include_next <fenv.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 87de8861ea42..7efa4ed2b39f 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP_FILESYSTEM
#define _LIBCPP_FILESYSTEM
@@ -14,36 +15,223 @@
namespace std::filesystem {
- class path;
+ // `class path` from http://eel.is/c++draft/fs.class.path.general#6
+ class path {
+ public:
+ using value_type = see below;
+ using string_type = basic_string<value_type>;
+ static constexpr value_type preferred_separator = see below;
+
+ enum format;
+
+ path() noexcept;
+ path(const path& p);
+ path(path&& p) noexcept;
+ path(string_type&& source, format fmt = auto_format);
+ template<class Source>
+ path(const Source& source, format fmt = auto_format);
+ template<class InputIterator>
+ path(InputIterator first, InputIterator last, format fmt = auto_format);
+ template<class Source>
+ path(const Source& source, const locale& loc, format fmt = auto_format);
+ template<class InputIterator>
+ path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
+ ~path();
+
+ path& operator=(const path& p);
+ path& operator=(path&& p) noexcept;
+ path& operator=(string_type&& source);
+ path& assign(string_type&& source);
+ template<class Source>
+ path& operator=(const Source& source);
+ template<class Source>
+ path& assign(const Source& source);
+ template<class InputIterator>
+ path& assign(InputIterator first, InputIterator last);
+
+ path& operator/=(const path& p);
+ template<class Source>
+ path& operator/=(const Source& source);
+ template<class Source>
+ path& append(const Source& source);
+ template<class InputIterator>
+ path& append(InputIterator first, InputIterator last);
+
+ path& operator+=(const path& x);
+ path& operator+=(const string_type& x);
+ path& operator+=(basic_string_view<value_type> x);
+ path& operator+=(const value_type* x);
+ path& operator+=(value_type x);
+ template<class Source>
+ path& operator+=(const Source& x);
+ template<class EcharT>
+ path& operator+=(EcharT x);
+ template<class Source>
+ path& concat(const Source& x);
+ template<class InputIterator>
+ path& concat(InputIterator first, InputIterator last);
+
+ void clear() noexcept;
+ path& make_preferred();
+ path& remove_filename();
+ path& replace_filename(const path& replacement);
+ path& replace_extension(const path& replacement = path());
+ void swap(path& rhs) noexcept;
+
+ friend bool operator==(const path& lhs, const path& rhs) noexcept;
+ friend bool operator!=(const path& lhs, const path& rhs) noexcept; // removed in C++20
+ friend bool operator< (const path& lhs, const path& rhs) noexcept; // removed in C++20
+ friend bool operator<=(const path& lhs, const path& rhs) noexcept; // removed in C++20
+ friend bool operator> (const path& lhs, const path& rhs) noexcept; // removed in C++20
+ friend bool operator>=(const path& lhs, const path& rhs) noexcept; // removed in C++20
+ friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; // C++20
+
+ friend path operator/(const path& lhs, const path& rhs);
+
+ const string_type& native() const noexcept;
+ const value_type* c_str() const noexcept;
+ operator string_type() const;
+
+ template<class EcharT, class traits = char_traits<EcharT>,
+ class Allocator = allocator<EcharT>>
+ basic_string<EcharT, traits, Allocator>
+ string(const Allocator& a = Allocator()) const;
+ std::string string() const;
+ std::wstring wstring() const;
+ std::u8string u8string() const;
+ std::u16string u16string() const;
+ std::u32string u32string() const;
+
+ template<class EcharT, class traits = char_traits<EcharT>,
+ class Allocator = allocator<EcharT>>
+ basic_string<EcharT, traits, Allocator>
+ generic_string(const Allocator& a = Allocator()) const;
+ std::string generic_string() const;
+ std::wstring generic_wstring() const;
+ std::u8string generic_u8string() const;
+ std::u16string generic_u16string() const;
+ std::u32string generic_u32string() const;
+
+ int compare(const path& p) const noexcept;
+ int compare(const string_type& s) const;
+ int compare(basic_string_view<value_type> s) const;
+ int compare(const value_type* s) const;
+
+ path root_name() const;
+ path root_directory() const;
+ path root_path() const;
+ path relative_path() const;
+ path parent_path() const;
+ path filename() const;
+ path stem() const;
+ path extension() const;
+
+ [[nodiscard]] bool empty() const noexcept;
+ bool has_root_name() const;
+ bool has_root_directory() const;
+ bool has_root_path() const;
+ bool has_relative_path() const;
+ bool has_parent_path() const;
+ bool has_filename() const;
+ bool has_stem() const;
+ bool has_extension() const;
+ bool is_absolute() const;
+ bool is_relative() const;
+
+ path lexically_normal() const;
+ path lexically_relative(const path& base) const;
+ path lexically_proximate(const path& base) const;
+
+ class iterator;
+ using const_iterator = iterator;
+
+ iterator begin() const;
+ iterator end() const;
+
+ 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);
+ };
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_entry {
+ public:
+ directory_entry() noexcept = default;
+ directory_entry(const directory_entry&) = default;
+ directory_entry(directory_entry&&) noexcept = default;
+ explicit directory_entry(const filesystem::path& p);
+ directory_entry(const filesystem::path& p, error_code& ec);
+ ~directory_entry();
+
+ directory_entry& operator=(const directory_entry&) = default;
+ directory_entry& operator=(directory_entry&&) noexcept = default;
+
+ void assign(const filesystem::path& p);
+ void assign(const filesystem::path& p, error_code& ec);
+ void replace_filename(const filesystem::path& p);
+ void replace_filename(const filesystem::path& p, error_code& ec);
+ void refresh();
+ void refresh(error_code& ec) noexcept;
+
+ const filesystem::path& path() const noexcept;
+ operator const filesystem::path&() const noexcept;
+ bool exists() const;
+ bool exists(error_code& ec) const noexcept;
+ bool is_block_file() const;
+ bool is_block_file(error_code& ec) const noexcept;
+ bool is_character_file() const;
+ bool is_character_file(error_code& ec) const noexcept;
+ bool is_directory() const;
+ bool is_directory(error_code& ec) const noexcept;
+ bool is_fifo() const;
+ bool is_fifo(error_code& ec) const noexcept;
+ bool is_other() const;
+ bool is_other(error_code& ec) const noexcept;
+ bool is_regular_file() const;
+ bool is_regular_file(error_code& ec) const noexcept;
+ bool is_socket() const;
+ bool is_socket(error_code& ec) const noexcept;
+ bool is_symlink() const;
+ bool is_symlink(error_code& ec) const noexcept;
+ uintmax_t file_size() const;
+ uintmax_t file_size(error_code& ec) const noexcept;
+ uintmax_t hard_link_count() const;
+ uintmax_t hard_link_count(error_code& ec) const noexcept;
+ file_time_type last_write_time() const;
+ file_time_type last_write_time(error_code& ec) const noexcept;
+ file_status status() const;
+ file_status status(error_code& ec) const noexcept;
+ file_status symlink_status() const;
+ file_status symlink_status(error_code& ec) const noexcept;
+
+ bool operator==(const directory_entry& rhs) const noexcept;
+ bool operator!=(const directory_entry& rhs) const noexcept; // removed in C++20
+ bool operator< (const directory_entry& rhs) const noexcept; // removed in C++20
+ bool operator<=(const directory_entry& rhs) const noexcept; // removed in C++20
+ bool operator> (const directory_entry& rhs) const noexcept; // removed in C++20
+ bool operator>=(const directory_entry& rhs) const noexcept; // removed in C++20
+ strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // since C++20
+
+ template<class charT, class traits>
+ friend basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const directory_entry& d);
+
+ private:
+ filesystem::path pathobject; // exposition only
+ friend class directory_iterator; // exposition only
+ };
class directory_iterator;
@@ -64,6 +252,8 @@
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
+
+ friend bool operator==(const space_info&, const space_info&) = default; // C++20
};
enum class file_type;
@@ -260,6 +450,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
#include <version>
// standard-mandated includes
+
+// [fs.filesystem.syn]
#include <compare>
#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
@@ -270,4 +462,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+#endif
+
#endif // _LIBCPP_FILESYSTEM
diff --git a/libcxx/include/float.h b/libcxx/include/float.h
index 606081251dfb..9e5f711fab83 100644
--- a/libcxx/include/float.h
+++ b/libcxx/include/float.h
@@ -76,7 +76,9 @@ Macros:
# pragma GCC system_header
#endif
-#include_next <float.h>
+#if __has_include_next(<float.h>)
+# include_next <float.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/format b/libcxx/include/format
index d2ec8fc23363..2c583c1065ba 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -23,16 +23,23 @@ namespace std {
using format_args = basic_format_args<format_context>;
using wformat_args = basic_format_args<wformat_context>;
- // [format.fmt.string], class template basic-format-string
+ // [format.fmt.string], class template basic_format_string
template<class charT, class... Args>
- struct basic-format-string; // exposition only
+ struct basic_format_string { // since C++23, exposition only before C++23
+ private:
+ basic_string_view<charT> str; // exposition only
+ public:
+ template<class T> consteval basic_format_string(const T& s);
+
+ constexpr basic_string_view<charT> get() const noexcept { return str; }
+ };
template<class... Args>
- using format-string = // exposition only
- basic-format-string<char, type_identity_t<Args>...>;
+ using format_string = // since C++23, exposition only before C++23
+ basic_format_string<char, type_identity_t<Args>...>;
template<class... Args>
- using wformat-string = // exposition only
- basic-format-string<wchar_t, type_identity_t<Args>...>;
+ using wformat_string = // since C++23, exposition only before C++23
+ basic_format_string<wchar_t, type_identity_t<Args>...>;
// [format.functions], formatting functions
template<class... Args>
@@ -105,6 +112,40 @@ namespace std {
using format_parse_context = basic_format_parse_context<char>;
using wformat_parse_context = basic_format_parse_context<wchar_t>;
+ // [format.range], formatting of ranges
+ // [format.range.fmtkind], variable template format_kind
+ enum class range_format { // since C++23
+ disabled,
+ map,
+ set,
+ sequence,
+ string,
+ debug_string
+ };
+
+ template<class R>
+ constexpr unspecified format_kind = unspecified; // since C++23
+
+ template<ranges::input_range R>
+ requires same_as<R, remove_cvref_t<R>>
+ constexpr range_format format_kind<R> = see below; // since C++23
+
+ // [format.range.formatter], class template range_formatter
+ template<class T, class charT = char>
+ requires same_as<remove_cvref_t<T>, T> && formattable<T, charT>
+ class range_formatter; // since C++23
+
+ // [format.range.fmtdef], class template range-default-formatter
+ template<range_format K, ranges::input_range R, class charT>
+ struct range-default-formatter; // exposition only, since C++23
+
+ // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr],
+ // specializations for maps, sets, and strings
+ template<ranges::input_range R, class charT>
+ requires (format_kind<R> != range_format::disabled) &&
+ formattable<ranges::range_reference_t<R>, charT>
+ struct formatter<R, charT> : range-default-formatter<format_kind<R>, R, charT> { }; // since C++23
+
// [format.arguments], arguments
// [format.arg], class template basic_format_arg
template<class Context> class basic_format_arg;
@@ -134,17 +175,17 @@ namespace std {
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
-#include <__algorithm/clamp.h>
#include <__config>
-#include <__debug>
#include <__format/buffer.h>
#include <__format/concepts.h>
+#include <__format/container_adaptor.h>
#include <__format/enable_insertable.h>
#include <__format/format_arg.h>
#include <__format/format_arg_store.h>
#include <__format/format_args.h>
#include <__format/format_context.h>
#include <__format/format_error.h>
+#include <__format/format_functions.h>
#include <__format/format_fwd.h>
#include <__format/format_parse_context.h>
#include <__format/format_string.h>
@@ -156,643 +197,16 @@ namespace std {
#include <__format/formatter_integer.h>
#include <__format/formatter_pointer.h>
#include <__format/formatter_string.h>
+#include <__format/formatter_tuple.h>
#include <__format/parser_std_format_spec.h>
+#include <__format/range_default_formatter.h>
+#include <__format/range_formatter.h>
#include <__format/unicode.h>
-#include <__iterator/back_insert_iterator.h>
-#include <__iterator/incrementable_traits.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 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 = format_context, class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
- return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
-}
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
- return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
-}
-#endif
-
-namespace __format {
-
-/// Helper class parse and handle argument.
-///
-/// When parsing a handle which is not enabled the code is ill-formed.
-/// This helper uses the parser of the appropriate formatter for the stored type.
-template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
-public:
- _LIBCPP_HIDE_FROM_ABI
- constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
-
- template <class _Tp>
- _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
- __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
- formatter<_Tp, _CharT> __f;
- __parse_ctx.advance_to(__f.parse(__parse_ctx));
- };
- }
-
- // Before calling __parse the proper handler needs to be set with __enable.
- // The default handler isn't a core constant expression.
- _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
- : __parse_([](basic_format_parse_context<_CharT>&) { __throw_format_error("Not a handle"); }) {}
-
-private:
- void (*__parse_)(basic_format_parse_context<_CharT>&);
-};
-
-// Dummy format_context only providing the parts used during constant
-// validation of the basic-format-string.
-template <class _CharT>
-struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
-public:
- using char_type = _CharT;
-
- _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
- const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
- : __args_(__args), __handles_(__handles), __size_(__size) {}
-
- // During the compile-time validation nothing needs to be written.
- // Therefore all operations of this iterator are a NOP.
- struct iterator {
- _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
- _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
- _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
- };
-
- _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
- if (__id >= __size_)
- __throw_format_error("Argument index out of bounds");
- return __args_[__id];
- }
-
- _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
- if (__id >= __size_)
- __throw_format_error("Argument index out of bounds");
- return __handles_[__id];
- }
-
- _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
- _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
-
-private:
- const __arg_t* __args_;
- const __compile_time_handle<_CharT>* __handles_;
- size_t __size_;
-};
-
-_LIBCPP_HIDE_FROM_ABI
-constexpr void __compile_time_validate_integral(__arg_t __type) {
- switch (__type) {
- case __arg_t::__int:
- case __arg_t::__long_long:
- case __arg_t::__i128:
- case __arg_t::__unsigned:
- case __arg_t::__unsigned_long_long:
- case __arg_t::__u128:
- return;
-
- default:
- __throw_format_error("Argument isn't an integral type");
- }
-}
-
-// _HasPrecision does the formatter have a precision?
-template <class _CharT, class _Tp, bool _HasPrecision = false>
-_LIBCPP_HIDE_FROM_ABI constexpr void
-__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
- __compile_time_basic_format_context<_CharT>& __ctx) {
- formatter<_Tp, _CharT> __formatter;
- __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
- // [format.string.std]/7
- // ... If the corresponding formatting argument is not of integral type, or
- // its value is negative for precision or non-positive for width, an
- // exception of type format_error is thrown.
- //
- // Validate whether the arguments are integrals.
- if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) {
- // TODO FMT Remove this when parser v1 has been phased out.
- if (__formatter.__width_needs_substitution())
- __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width));
-
- if constexpr (_HasPrecision)
- if (__formatter.__precision_needs_substitution())
- __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision));
- } else {
- if (__formatter.__parser_.__width_as_arg_)
- __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
-
- if constexpr (_HasPrecision)
- if (__formatter.__parser_.__precision_as_arg_)
- __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
- }
-}
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
- __compile_time_basic_format_context<_CharT>& __ctx,
- __arg_t __type) {
- switch (__type) {
- case __arg_t::__none:
- __throw_format_error("Invalid argument");
- case __arg_t::__boolean:
- return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
- case __arg_t::__char_type:
- return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
- case __arg_t::__int:
- return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
- case __arg_t::__long_long:
- return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
- case __arg_t::__i128:
-# ifndef _LIBCPP_HAS_NO_INT128
- return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
-# else
- __throw_format_error("Invalid argument");
-# endif
- return;
- case __arg_t::__unsigned:
- return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
- case __arg_t::__unsigned_long_long:
- return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
- case __arg_t::__u128:
-# ifndef _LIBCPP_HAS_NO_INT128
- return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
-# else
- __throw_format_error("Invalid argument");
-# endif
- return;
- case __arg_t::__float:
- return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
- case __arg_t::__double:
- return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
- case __arg_t::__long_double:
- return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
- case __arg_t::__const_char_type_ptr:
- return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
- case __arg_t::__string_view:
- return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
- case __arg_t::__ptr:
- return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
- case __arg_t::__handle:
- __throw_format_error("Handle should use __compile_time_validate_handle_argument");
- }
- __throw_format_error("Invalid argument");
-}
-
-template <class _CharT, class _ParseCtx, class _Ctx>
-_LIBCPP_HIDE_FROM_ABI constexpr 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);
-
- bool __parse = *__r.__ptr == _CharT(':');
- 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 '}'");
- }
-
- if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
- __arg_t __type = __ctx.arg(__r.__value);
- if (__type == __arg_t::__handle)
- __ctx.__handle(__r.__value).__parse(__parse_ctx);
- else
- __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
- } else
- _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;
- if (__parse)
- __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 constexpr 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 _CharT, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS __basic_format_string {
- basic_string_view<_CharT> __str_;
-
- template <class _Tp>
- requires convertible_to<const _Tp&, basic_string_view<_CharT>>
- consteval __basic_format_string(const _Tp& __str) : __str_{__str} {
- __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
- _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
- }
-
-private:
- using _Context = __format::__compile_time_basic_format_context<_CharT>;
-
- static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
- __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
-
- // TODO FMT remove this work-around when the AIX ICE has been resolved.
-# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
- template <class _Tp>
- static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
- __format::__compile_time_handle<_CharT> __handle;
- if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
- __handle.template __enable<_Tp>();
-
- return __handle;
- }
-
- static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
- __get_handle<_Args>()...};
-# else
- static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
- using _Tp = remove_cvref_t<_Args>;
- __format::__compile_time_handle<_CharT> __handle;
- if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
- __handle.template __enable<_Tp>();
-
- return __handle;
- }()...};
-# endif
-};
-
-template <class... _Args>
-using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>;
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <class... _Args>
-using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>;
-#endif
-
-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 {
- __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
- _VSTD::__format::__vformat_to(
- basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(),
- __args));
- return _VSTD::move(__buffer).out();
- }
-}
-
-// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
-// https://reviews.llvm.org/D110499#inline-1180704
-// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
-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, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
- _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, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
- _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(__format_string_t<_Args...> __fmt,
- _Args&&... __args) {
- return _VSTD::vformat(__fmt.__str_, _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(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...));
-}
-#endif
-
-template <class _Context, class _OutIt, class _CharT>
-_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
- basic_string_view<_CharT> __fmt,
- basic_format_args<_Context> __args) {
- __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
- _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
- return _VSTD::move(__buffer).result();
-}
-
-template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...));
-}
-
-#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, __wformat_string_t<_Args...> __fmt,
- _Args&&... __args) {
- return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...));
-}
-#endif
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
- __format::__formatted_size_buffer<_CharT> __buffer;
- _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
- return _VSTD::move(__buffer).result();
-}
-
-template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
-}
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
-}
-#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 {
- __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
- _VSTD::__format::__vformat_to(
- basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(),
- __args, _VSTD::move(__loc)));
- return _VSTD::move(__buffer).out();
- }
-}
-
-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, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
- _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, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
- _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,
- __format_string_t<_Args...> __fmt,
- _Args&&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
- _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, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
- _VSTD::make_wformat_args(__args...));
-}
-#endif
-
-template <class _Context, class _OutIt, class _CharT>
-_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
- locale __loc, basic_string_view<_CharT> __fmt,
- basic_format_args<_Context> __args) {
- __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
- _VSTD::__format::__vformat_to(
- basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
- return _VSTD::move(__buffer).result();
-}
-
-template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _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, __format_string_t<_Args...> __fmt,
- _Args&&... __args) {
- return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
- _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 format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt,
- _Args&&... __args) {
- return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
- _VSTD::make_wformat_args(__args...));
-}
-#endif
-
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
- __format::__formatted_size_buffer<_CharT> __buffer;
- _VSTD::__format::__vformat_to(
- basic_format_parse_context{__fmt, __args.__size()},
- _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
- return _VSTD::move(__buffer).result();
-}
-
-template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
-}
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
-}
-#endif
-
-#endif // _LIBCPP_HAS_NO_LOCALIZATION
-
-#endif //_LIBCPP_STD_VER > 17
-
-_LIBCPP_END_NAMESPACE_STD
-
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
#endif // _LIBCPP_FORMAT
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index ee90aaa4771f..61dde8167dfc 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -188,19 +188,22 @@ template <class T, class Allocator, class Predicate>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_destructor.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory/unique_ptr.h>
+#include <__memory_resource/polymorphic_allocator.h>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
+#include <__utility/move.h>
#include <limits>
-#include <memory>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -239,30 +242,23 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
template <class _NodePtr>
struct __forward_node_traits {
- typedef typename remove_cv<
- typename pointer_traits<_NodePtr>::element_type>::type __node;
+ typedef __remove_cv_t<
+ typename pointer_traits<_NodePtr>::element_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;
+ typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
+ typedef __rebind_pointer_t<_NodePtr, void> __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;
+ typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer>
+ __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;
+ typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer>
+ __non_iter_node_pointer;
_LIBCPP_INLINE_VISIBILITY
static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
@@ -278,7 +274,7 @@ template <class _NodePtr>
struct __forward_begin_node
{
typedef _NodePtr pointer;
- typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
+ typedef __rebind_pointer_t<_NodePtr, __forward_begin_node> __begin_node_pointer;
pointer __next_;
@@ -291,16 +287,11 @@ struct __forward_begin_node
};
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;
-};
+using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;
template <class _Tp, class _VoidPtr>
struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
- : public __begin_node_of<_Tp, _VoidPtr>::type
+ : public __begin_node_of<_Tp, _VoidPtr>
{
typedef _Tp value_type;
@@ -353,7 +344,7 @@ public:
typedef value_type& reference;
typedef typename pointer_traits<__node_pointer>::difference_type
difference_type;
- typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
+ typedef __rebind_pointer_t<__node_pointer, value_type> pointer;
_LIBCPP_INLINE_VISIBILITY
__forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
@@ -434,7 +425,7 @@ public:
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
+ typedef __rebind_pointer_t<__node_pointer, const value_type>
pointer;
_LIBCPP_INLINE_VISIBILITY
@@ -482,14 +473,12 @@ protected:
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 __begin_node_of<value_type, void_pointer> __begin_node;
+ typedef __rebind_alloc<allocator_traits<allocator_type>, __node> __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 __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;
typedef typename allocator_traits<__begin_node_allocator>::pointer
__begin_node_pointer;
@@ -497,6 +486,10 @@ protected:
"internal allocator type must differ from user-specified "
"type; otherwise overload resolution breaks");
+ static_assert(is_same<allocator_type, __rebind_alloc<__node_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
_LIBCPP_INLINE_VISIBILITY
@@ -852,7 +845,7 @@ public:
__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>());}
+ __remove_return_type unique() { return unique(__equal_to()); }
template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
@@ -1702,6 +1695,7 @@ forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
}
template <class _Tp, class _Alloc>
+_LIBCPP_HIDE_FROM_ABI
bool operator==(const forward_list<_Tp, _Alloc>& __x,
const forward_list<_Tp, _Alloc>& __y)
{
@@ -1785,6 +1779,25 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _ValueT>
+using forward_list = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <atomic>
+# include <concepts>
+# include <functional>
+# include <iosfwd>
+# include <iterator>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_FORWARD_LIST
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index ffa75b14eb15..41e95bf3dc66 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -192,6 +192,7 @@ typedef basic_fstream<wchar_t> wfstream;
#include <cstring>
#include <istream>
#include <ostream>
+#include <typeinfo>
#include <version>
#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
@@ -209,6 +210,8 @@ _LIBCPP_PUSH_MACROS
# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
#endif
+#if !defined(_LIBCPP_HAS_NO_FSTREAM)
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
@@ -226,7 +229,7 @@ public:
// 27.9.1.2 Constructors/destructor:
basic_filebuf();
basic_filebuf(basic_filebuf&& __rhs);
- virtual ~basic_filebuf();
+ ~basic_filebuf() override;
// 27.9.1.3 Assign/swap:
_LIBCPP_INLINE_VISIBILITY
@@ -259,16 +262,16 @@ public:
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);
+ int_type underflow() override;
+ int_type pbackfail(int_type __c = traits_type::eof()) override;
+ int_type overflow (int_type __c = traits_type::eof()) override;
+ basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n) override;
+ pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __wch = ios_base::in | ios_base::out) override;
+ pos_type seekpos(pos_type __sp,
+ ios_base::openmode __wch = ios_base::in | ios_base::out) override;
+ int sync() override;
+ void imbue(const locale& __loc) override;
private:
char* __extbuf_;
@@ -310,9 +313,9 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
__owns_ib_(false),
__always_noconv_(false)
{
- if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
+ if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
{
- __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
+ __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(this->getloc());
__always_noconv_ = __cv_->always_noconv();
}
setbuf(nullptr, 4096);
@@ -731,7 +734,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
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);
+ const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
int_type __c = traits_type::eof();
if (this->gptr() == this->egptr())
{
@@ -739,7 +742,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
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_);
+ __nmemb = ::fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
if (__nmemb != 0)
{
this->setg(this->eback(),
@@ -750,9 +753,11 @@ basic_filebuf<_CharT, _Traits>::underflow()
}
else
{
- _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
- if (__extbufend_ != __extbufnext_)
+ if (__extbufend_ != __extbufnext_) {
+ _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
+ _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
_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),
@@ -835,7 +840,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
if (__always_noconv_)
{
size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
- if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
+ if (std::fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
return traits_type::eof();
}
else
@@ -855,7 +860,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
if (__r == codecvt_base::noconv)
{
size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
- if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
+ if (std::fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
return traits_type::eof();
}
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
@@ -963,7 +968,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
return pos_type(off_type(-1));
pos_type __r = ftell(__file_);
#else
- if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
+ if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
return pos_type(off_type(-1));
pos_type __r = ftello(__file_);
#endif
@@ -981,7 +986,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
if (fseek(__file_, __sp, SEEK_SET))
return pos_type(off_type(-1));
#else
- if (fseeko(__file_, __sp, SEEK_SET))
+ if (::fseeko(__file_, __sp, SEEK_SET))
return pos_type(off_type(-1));
#endif
__st_ = __sp.state();
@@ -1045,7 +1050,7 @@ basic_filebuf<_CharT, _Traits>::sync()
if (fseek(__file_, -__c, SEEK_CUR))
return -1;
#else
- if (fseeko(__file_, -__c, SEEK_CUR))
+ if (::fseeko(__file_, -__c, SEEK_CUR))
return -1;
#endif
if (__update_st)
@@ -1062,7 +1067,7 @@ void
basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
{
sync();
- __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(__loc);
bool __old_anc = __always_noconv_;
__always_noconv_ = __cv_->always_noconv();
if (__old_anc != __always_noconv_)
@@ -1741,6 +1746,18 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
_LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_HAS_NO_FSTREAM
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <iosfwd>
+# include <limits>
+# include <new>
+# include <stdexcept>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_FSTREAM
diff --git a/libcxx/include/functional b/libcxx/include/functional
index de02059f642a..8589d3a9d6a9 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -531,20 +531,20 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <__functional/unary_negate.h>
#include <__functional/unwrap_ref.h>
#include <__utility/forward.h>
-#include <concepts>
#include <exception>
-#include <memory>
-#include <tuple>
+#include <memory> // TODO: find out why removing this breaks the modules build
#include <type_traits>
#include <typeinfo>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <utility>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <tuple>
+# include <utility>
+#endif
+
#endif // _LIBCPP_FUNCTIONAL
diff --git a/libcxx/include/future b/libcxx/include/future
index cedab3608ad2..2f14a471c458 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -367,21 +367,19 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <__chrono/time_point.h>
#include <__config>
#include <__memory/allocator_arg_t.h>
+#include <__memory/allocator_destructor.h>
#include <__memory/uses_allocator.h>
+#include <__type_traits/strip_signature.h>
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <exception>
-#include <memory>
#include <mutex>
+#include <new>
#include <system_error>
#include <thread>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -518,7 +516,7 @@ public:
const error_code& code() const _NOEXCEPT {return __ec_;}
future_error(const future_error&) _NOEXCEPT = default;
- virtual ~future_error() _NOEXCEPT;
+ ~future_error() _NOEXCEPT override;
};
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
@@ -544,7 +542,7 @@ protected:
mutable condition_variable __cv_;
unsigned __state_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
void __sub_wait(unique_lock<mutex>& __lk);
public:
enum
@@ -627,11 +625,13 @@ class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
: public __assoc_sub_state
{
typedef __assoc_sub_state base;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
_Up __value_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
template <class _Arg>
@@ -641,7 +641,7 @@ public:
void set_value_at_thread_exit(_Arg&& __arg);
_Rp move();
- typename add_lvalue_reference<_Rp>::type copy();
+ __add_lvalue_reference_t<_Rp> copy();
};
template <class _Rp>
@@ -687,18 +687,18 @@ __assoc_state<_Rp>::move()
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
}
template <class _Rp>
-typename add_lvalue_reference<_Rp>::type
+__add_lvalue_reference_t<_Rp>
__assoc_state<_Rp>::copy()
{
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return *reinterpret_cast<_Rp*>(&__value_);
}
@@ -711,7 +711,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>
protected:
_Up __value_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
void set_value(_Rp& __arg);
@@ -758,7 +758,7 @@ __assoc_state<_Rp&>::copy()
unique_lock<mutex> __lk(this->__mut_);
this->__sub_wait(__lk);
if (this->__exception_ != nullptr)
- rethrow_exception(this->__exception_);
+ std::rethrow_exception(this->__exception_);
return *__value_;
}
@@ -823,7 +823,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc
typedef __assoc_sub_state base;
_Alloc __alloc_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
_LIBCPP_INLINE_VISIBILITY
explicit __assoc_sub_state_alloc(const _Alloc& __a)
@@ -895,7 +895,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit __deferred_assoc_state(_Fp&& __f);
- virtual void __execute();
+ void __execute() override;
};
template <class _Fp>
@@ -982,12 +982,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
_Fp __func_;
- virtual void __on_zero_shared() _NOEXCEPT;
+ void __on_zero_shared() _NOEXCEPT override;
public:
_LIBCPP_INLINE_VISIBILITY
explicit __async_assoc_state(_Fp&& __f);
- virtual void __execute();
+ void __execute() override;
};
template <class _Fp>
@@ -1628,7 +1628,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>
public:
_LIBCPP_INLINE_VISIBILITY
__packaged_task_base() {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual ~__packaged_task_base() {}
virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
virtual void destroy() = 0;
@@ -1704,7 +1704,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
__base* __get_buf() { return (__base*)&__buf_; }
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<3*sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __f_;
public:
@@ -1754,7 +1756,7 @@ 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 __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
@@ -1778,7 +1780,7 @@ __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 __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
@@ -1837,7 +1839,9 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)
{
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __t = (__base*)&__tempbuf;
__f_->__move_to(__t);
__f_->destroy();
@@ -1891,11 +1895,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_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> >
+ class = __enable_if_t<!is_same<__remove_cvref_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)),
@@ -2006,11 +2010,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
packaged_task() _NOEXCEPT : __p_(nullptr) {}
template <class _Fp,
- class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
+ class = __enable_if_t<!is_same<__remove_cvref_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> >
+ class = __enable_if_t<!is_same<__remove_cvref_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)),
@@ -2053,6 +2057,16 @@ public:
void reset();
};
+#if _LIBCPP_STD_VER >= 17
+
+template <class _Rp, class... _Args>
+packaged_task(_Rp(*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
+
+template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
+packaged_task(_Fp) -> packaged_task<_Stripped>;
+
+#endif
+
template<class ..._ArgTypes>
void
packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
@@ -2174,7 +2188,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau
{ return (int(__policy) & int(__value)) != 0; }
template <class _Fp, class... _Args>
-_LIBCPP_NODISCARD_AFTER_CXX17
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
async(launch __policy, _Fp&& __f, _Args&&... __args)
{
@@ -2436,4 +2450,8 @@ future<void>::share() _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+# include <chrono>
+#endif
+
#endif // _LIBCPP_FUTURE
diff --git a/libcxx/include/initializer_list b/libcxx/include/initializer_list
index 02a8ec57fab3..d97572214404 100644
--- a/libcxx/include/initializer_list
+++ b/libcxx/include/initializer_list
@@ -62,7 +62,7 @@ class _LIBCPP_TEMPLATE_VIS initializer_list
size_t __size_;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
: __begin_(__b),
__size_(__s)
@@ -77,25 +77,25 @@ public:
typedef const _Ep* const_iterator;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
size_t size() const _NOEXCEPT {return __size_;}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Ep* begin() const _NOEXCEPT {return __begin_;}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
};
template<class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_CONSTEXPR_SINCE_CXX14
const _Ep*
begin(initializer_list<_Ep> __il) _NOEXCEPT
{
@@ -104,7 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT
template<class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_CONSTEXPR_SINCE_CXX14
const _Ep*
end(initializer_list<_Ep> __il) _NOEXCEPT
{
diff --git a/libcxx/include/inttypes.h b/libcxx/include/inttypes.h
index e0fd71f9b65d..b755526b8492 100644
--- a/libcxx/include/inttypes.h
+++ b/libcxx/include/inttypes.h
@@ -248,7 +248,9 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
# define __STDC_FORMAT_MACROS
#endif
-#include_next <inttypes.h>
+#if __has_include_next(<inttypes.h>)
+# include_next <inttypes.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip
index ed8334519ae8..38c5c9b9c6b2 100644
--- a/libcxx/include/iomanip
+++ b/libcxx/include/iomanip
@@ -278,7 +278,7 @@ setw(int __n)
template <class _MoneyT> class __iom_t7;
template <class _CharT, class _Traits, class _MoneyT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
template <class _MoneyT>
@@ -298,7 +298,7 @@ public:
};
template <class _CharT, class _Traits, class _MoneyT>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -311,7 +311,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
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());
+ const _Fp& __mf = std::use_facet<_Fp>(__is.getloc());
__mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
__is.setstate(__err);
}
@@ -338,7 +338,7 @@ get_money(_MoneyT& __mon, bool __intl = false)
template <class _MoneyT> class __iom_t8;
template <class _CharT, class _Traits, class _MoneyT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
template <class _MoneyT>
@@ -358,7 +358,7 @@ public:
};
template <class _CharT, class _Traits, class _MoneyT>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -370,7 +370,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
{
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
typedef money_put<_CharT, _Op> _Fp;
- const _Fp& __mf = use_facet<_Fp>(__os.getloc());
+ const _Fp& __mf = std::use_facet<_Fp>(__os.getloc());
if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
__os.setstate(ios_base::badbit);
}
@@ -397,7 +397,7 @@ put_money(const _MoneyT& __mon, bool __intl = false)
template <class _CharT> class __iom_t9;
template <class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
template <class _CharT>
@@ -417,7 +417,7 @@ public:
};
template <class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -430,7 +430,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
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());
+ const _Fp& __tf = std::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);
@@ -458,7 +458,7 @@ get_time(tm* __tm, const _CharT* __fmt)
template <class _CharT> class __iom_t10;
template <class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
template <class _CharT>
@@ -478,7 +478,7 @@ public:
};
template <class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -490,7 +490,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
{
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
typedef time_put<_CharT, _Op> _Fp;
- const _Fp& __tf = use_facet<_Fp>(__os.getloc());
+ const _Fp& __tf = std::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);
diff --git a/libcxx/include/ios b/libcxx/include/ios
index 7140e00b406a..9eecf4d8dd8f 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -224,6 +224,8 @@ storage-class-specifier const error_category& iostream_category() noexcept;
#include <version>
// standard-mandated includes
+
+// [ios.syn]
#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
@@ -441,7 +443,7 @@ 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;
+ ~failure() _NOEXCEPT override;
};
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
@@ -641,7 +643,7 @@ public:
// 27.5.4.1 Constructor/destructor:
_LIBCPP_INLINE_VISIBILITY
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
- virtual ~basic_ios();
+ ~basic_ios() override;
// 27.5.4.2 Members:
_LIBCPP_INLINE_VISIBILITY
@@ -764,7 +766,7 @@ 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);
+ return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
}
template <class _CharT, class _Traits>
@@ -772,7 +774,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::widen(char __c) const
{
- return use_facet<ctype<char_type> >(getloc()).widen(__c);
+ return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
}
template <class _CharT, class _Traits>
@@ -842,7 +844,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _
ios_base::set_rdbuf(__sb);
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
boolalpha(ios_base& __str)
{
@@ -850,7 +852,7 @@ boolalpha(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
noboolalpha(ios_base& __str)
{
@@ -858,7 +860,7 @@ noboolalpha(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
showbase(ios_base& __str)
{
@@ -866,7 +868,7 @@ showbase(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
noshowbase(ios_base& __str)
{
@@ -874,7 +876,7 @@ noshowbase(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
showpoint(ios_base& __str)
{
@@ -882,7 +884,7 @@ showpoint(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
noshowpoint(ios_base& __str)
{
@@ -890,7 +892,7 @@ noshowpoint(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
showpos(ios_base& __str)
{
@@ -898,7 +900,7 @@ showpos(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
noshowpos(ios_base& __str)
{
@@ -906,7 +908,7 @@ noshowpos(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
skipws(ios_base& __str)
{
@@ -914,7 +916,7 @@ skipws(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
noskipws(ios_base& __str)
{
@@ -922,7 +924,7 @@ noskipws(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
uppercase(ios_base& __str)
{
@@ -930,7 +932,7 @@ uppercase(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
nouppercase(ios_base& __str)
{
@@ -938,7 +940,7 @@ nouppercase(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
unitbuf(ios_base& __str)
{
@@ -946,7 +948,7 @@ unitbuf(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
nounitbuf(ios_base& __str)
{
@@ -954,7 +956,7 @@ nounitbuf(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
internal(ios_base& __str)
{
@@ -962,7 +964,7 @@ internal(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
left(ios_base& __str)
{
@@ -970,7 +972,7 @@ left(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
right(ios_base& __str)
{
@@ -978,7 +980,7 @@ right(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
dec(ios_base& __str)
{
@@ -986,7 +988,7 @@ dec(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
hex(ios_base& __str)
{
@@ -994,7 +996,7 @@ hex(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
oct(ios_base& __str)
{
@@ -1002,7 +1004,7 @@ oct(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
fixed(ios_base& __str)
{
@@ -1010,7 +1012,7 @@ fixed(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
scientific(ios_base& __str)
{
@@ -1018,7 +1020,7 @@ scientific(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
hexfloat(ios_base& __str)
{
@@ -1026,7 +1028,7 @@ hexfloat(ios_base& __str)
return __str;
}
-inline
+_LIBCPP_HIDE_FROM_ABI inline
ios_base&
defaultfloat(ios_base& __str)
{
@@ -1036,4 +1038,17 @@ defaultfloat(ios_base& __str)
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <cstddef>
+# include <cstdlib>
+# include <cstring>
+# include <initializer_list>
+# include <limits>
+# include <new>
+# include <stdexcept>
+# include <type_traits>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_IOS
diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd
index 9cd9450e62e9..7948606e6453 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -96,6 +96,7 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__fwd/string.h>
#include <__mbstate_t.h>
#include <version>
@@ -107,19 +108,6 @@ _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;
@@ -242,18 +230,6 @@ typedef long int streamoff; // for char_traits in <string>
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
-
-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;
diff --git a/libcxx/include/iostream b/libcxx/include/iostream
index 13d4ac3cadae..d679d9932d7e 100644
--- a/libcxx/include/iostream
+++ b/libcxx/include/iostream
@@ -38,6 +38,8 @@ extern wostream wclog;
#include <version>
// standard-mandated includes
+
+// [iostream.syn]
#include <ios>
#include <istream>
#include <ostream>
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 7af5dfa474cd..6e67d61de2af 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -192,7 +192,7 @@ public:
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();
+ ~basic_istream() override;
protected:
inline _LIBCPP_INLINE_VISIBILITY
basic_istream(basic_istream&& __rhs);
@@ -316,7 +316,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
if (!__noskipws && (__is.flags() & ios_base::skipws))
{
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
_Ip __i(__is);
_Ip __eof;
for (; __i != __eof; ++__i)
@@ -366,7 +366,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
#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);
+ std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -476,7 +476,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
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);
+ std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
if (__temp < numeric_limits<_Tp>::min())
{
__state |= ios_base::failbit;
@@ -536,7 +536,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
{
#endif
_CharT* __s = __p;
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (__s != __p + (__n-1))
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@@ -633,7 +633,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
#endif // _LIBCPP_STD_VER > 17
template<class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
{
ios_base::iostate __state = ios_base::goodbit;
@@ -1329,7 +1329,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
}
template <class _CharT, class _Traits>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is)
{
ios_base::iostate __state = ios_base::goodbit;
@@ -1340,7 +1340,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (true)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@@ -1375,7 +1375,7 @@ struct __is_istreamable : false_type { };
template <class _Stream, class _Tp>
struct __is_istreamable<_Stream, _Tp, decltype(
- declval<_Stream>() >> declval<_Tp>(), void()
+ std::declval<_Stream>() >> std::declval<_Tp>(), void()
)> : true_type { };
template <class _Stream, class _Tp, class = typename enable_if<
@@ -1408,7 +1408,7 @@ public:
: basic_istream<_CharT, _Traits>(__sb)
{}
- virtual ~basic_iostream();
+ ~basic_iostream() override;
protected:
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream(basic_iostream&& __rhs);
@@ -1442,7 +1442,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()
}
template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
@@ -1461,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
if (__n <= 0)
__n = numeric_limits<streamsize>::max();
streamsize __c = 0;
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (__c < __n)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@@ -1498,7 +1498,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
}
template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
@@ -1556,7 +1556,7 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
- return getline(__is, __str, __is.widen('\n'));
+ return std::getline(__is, __str, __is.widen('\n'));
}
template<class _CharT, class _Traits, class _Allocator>
@@ -1565,7 +1565,7 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
- return getline(__is, __str, __dlm);
+ return std::getline(__is, __str, __dlm);
}
template<class _CharT, class _Traits, class _Allocator>
@@ -1574,11 +1574,11 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
- return getline(__is, __str, __is.widen('\n'));
+ return std::getline(__is, __str, __is.widen('\n'));
}
template <class _CharT, class _Traits, size_t _Size>
-basic_istream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
ios_base::iostate __state = ios_base::goodbit;
@@ -1590,7 +1590,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
#endif
basic_string<_CharT, _Traits> __str;
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
size_t __c = 0;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
@@ -1637,6 +1637,11 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <type_traits>
+#endif
+
_LIBCPP_POP_MACROS
#endif // _LIBCPP_ISTREAM
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 225ae815363c..35eca67b4a5e 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -717,22 +717,26 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#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 <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
+// standard-mandated includes
+
+// [iterator.synopsis]
+#include <compare>
+#include <concepts>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <exception>
# include <new>
+# include <type_traits>
# include <typeinfo>
# include <utility>
#endif
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
#endif // _LIBCPP_ITERATOR
diff --git a/libcxx/include/latch b/libcxx/include/latch
index 85936750b4c1..ff17f8453ea5 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -64,7 +64,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class latch
{
- __atomic_base<ptrdiff_t> __a;
+ __atomic_base<ptrdiff_t> __a_;
public:
static constexpr ptrdiff_t max() noexcept {
@@ -72,7 +72,7 @@ public:
}
inline _LIBCPP_INLINE_VISIBILITY
- constexpr explicit latch(ptrdiff_t __expected) : __a(__expected) { }
+ constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { }
~latch() = default;
latch(const latch&) = delete;
@@ -81,19 +81,19 @@ public:
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void count_down(ptrdiff_t __update = 1)
{
- auto const __old = __a.fetch_sub(__update, memory_order_release);
+ auto const __old = __a_.fetch_sub(__update, memory_order_release);
if(__old == __update)
- __a.notify_all();
+ __a_.notify_all();
}
inline _LIBCPP_INLINE_VISIBILITY
bool try_wait() const noexcept
{
- return 0 == __a.load(memory_order_acquire);
+ return 0 == __a_.load(memory_order_acquire);
}
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait() const
{
- __cxx_atomic_wait(&__a.__a_, [&]() -> bool {
+ __cxx_atomic_wait(&__a_.__a_, [&]() -> bool {
return try_wait();
});
}
diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
new file mode 100644
index 000000000000..575ce0f79d47
--- /dev/null
+++ b/libcxx/include/libcxx.imp
@@ -0,0 +1,45 @@
+[
+ { include: [ "<__hash_table>", "private", "<unordered_map>", "public" ] },
+ { include: [ "<__hash_table>", "private", "<unordered_set>", "public" ] },
+ { include: [ "<__locale>", "private", "<locale>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<map>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<set>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<unordered_map>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<unordered_set>", "public" ] },
+ { include: [ "<__split_buffer>", "private", "<deque>", "public" ] },
+ { include: [ "<__split_buffer>", "private", "<vector>", "public" ] },
+ { include: [ "<__std_stream>", "private", "<iostream>", "public" ] },
+ { include: [ "<__threading_support>", "private", "<atomic>", "public" ] },
+ { include: [ "<__threading_support>", "private", "<mutex>", "public" ] },
+ { include: [ "<__threading_support>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__threading_support>", "private", "<thread>", "public" ] },
+ { include: [ "<__tree>", "private", "<map>", "public" ] },
+ { include: [ "<__tree>", "private", "<set>", "public" ] },
+ { include: [ "@<__algorithm/.*>", "private", "<algorithm>", "public" ] },
+ { include: [ "@<__bit/.*>", "private", "<bit>", "public" ] },
+ { include: [ "@<__charconv/.*>", "private", "<charconv>", "public" ] },
+ { include: [ "@<__chrono/.*>", "private", "<chrono>", "public" ] },
+ { include: [ "@<__compare/.*>", "private", "<compare>", "public" ] },
+ { include: [ "@<__concepts/.*>", "private", "<concepts>", "public" ] },
+ { include: [ "@<__coroutine/.*>", "private", "<coroutine>", "public" ] },
+ { include: [ "@<__debug_utils/.*>", "private", "<debug_utils>", "public" ] },
+ { include: [ "@<__expected/.*>", "private", "<expected>", "public" ] },
+ { include: [ "@<__filesystem/.*>", "private", "<filesystem>", "public" ] },
+ { include: [ "@<__format/.*>", "private", "<format>", "public" ] },
+ { include: [ "@<__functional/.*>", "private", "<functional>", "public" ] },
+ { include: [ "@<__fwd/.*>", "private", "<fwd>", "public" ] },
+ { include: [ "@<__ios/.*>", "private", "<ios>", "public" ] },
+ { include: [ "@<__iterator/.*>", "private", "<iterator>", "public" ] },
+ { include: [ "@<__memory/.*>", "private", "<memory>", "public" ] },
+ { include: [ "@<__memory_resource/.*>", "private", "<memory_resource>", "public" ] },
+ { include: [ "@<__numeric/.*>", "private", "<numeric>", "public" ] },
+ { include: [ "@<__random/.*>", "private", "<random>", "public" ] },
+ { include: [ "@<__ranges/.*>", "private", "<ranges>", "public" ] },
+ { include: [ "@<__string/.*>", "private", "<string>", "public" ] },
+ { include: [ "@<__support/.*>", "private", "<support>", "public" ] },
+ { include: [ "@<__thread/.*>", "private", "<thread>", "public" ] },
+ { include: [ "@<__tuple_dir/.*>", "private", "<tuple>", "public" ] },
+ { include: [ "@<__type_traits/.*>", "private", "<type_traits>", "public" ] },
+ { include: [ "@<__utility/.*>", "private", "<utility>", "public" ] },
+ { include: [ "@<__variant/.*>", "private", "<variant>", "public" ] },
+]
diff --git a/libcxx/include/limits b/libcxx/include/limits
index 1fa3a8228fd8..9f5949e63cff 100644
--- a/libcxx/include/limits
+++ b/libcxx/include/limits
@@ -104,11 +104,9 @@ template<> class numeric_limits<cv long double>;
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <type_traits>
-
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include "__support/win32/limits_msvc_win32.h"
-#endif // _LIBCPP_MSVCRT
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/remove_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -432,7 +430,7 @@ protected:
_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__))
+#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
#else
static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
@@ -451,9 +449,9 @@ protected:
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS numeric_limits
- : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
+ : private __libcpp_numeric_limits<__remove_cv_t<_Tp> >
{
- typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
+ typedef __libcpp_numeric_limits<__remove_cv_t<_Tp> > __base;
typedef typename __base::type type;
public:
static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
@@ -825,4 +823,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_LIMITS
diff --git a/libcxx/include/limits.h b/libcxx/include/limits.h
index 3e1e85a8a0b4..537a4b1439f9 100644
--- a/libcxx/include/limits.h
+++ b/libcxx/include/limits.h
@@ -43,13 +43,13 @@ Macros:
# pragma GCC system_header
#endif
-#ifndef __GNUC__
-#include_next <limits.h>
-#else
+#ifdef _LIBCPP_COMPILER_GCC
+
// 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:
+// #include_next GCC's limits.h (reasons not entirely clear to me).
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795 for more details.
+// 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_
@@ -59,6 +59,13 @@ Macros:
// Get the ISO C defines
#undef _GCC_LIMITS_H_
#include_next <limits.h>
-#endif // __GNUC__
+
+#else
+
+# if __has_include_next(<limits.h>)
+# include_next <limits.h>
+# endif
+
+#endif // _LIBCPP_COMPILER_GCC
#endif // _LIBCPP_LIMITS_H
diff --git a/libcxx/include/list b/libcxx/include/list
index 5fcbd67c6703..a0c732739ca2 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -194,21 +194,24 @@ template <class T, class Allocator, class Predicate>
#include <__iterator/next.h>
#include <__iterator/prev.h>
#include <__iterator/reverse_iterator.h>
+#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_destructor.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory/unique_ptr.h>
+#include <__memory_resource/polymorphic_allocator.h>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/swap.h>
+#include <cstring>
#include <limits>
-#include <memory>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -237,26 +240,19 @@ 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
+ typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> >
__node_pointer;
- typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
+ typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >
__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;
+ typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer;
#endif
- typedef typename conditional<
- is_same<__link_pointer, __node_pointer>::value,
- __base_pointer,
- __node_pointer
- >::type __non_link_pointer;
+ typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer>
+ __non_link_pointer;
static _LIBCPP_INLINE_VISIBILITY
__link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
@@ -340,7 +336,7 @@ 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 __rebind_pointer_t<_VoidPtr, value_type> pointer;
typedef typename pointer_traits<pointer>::difference_type difference_type;
_LIBCPP_INLINE_VISIBILITY
@@ -448,7 +444,7 @@ 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 __rebind_pointer_t<_VoidPtr, const value_type> pointer;
typedef typename pointer_traits<pointer>::difference_type difference_type;
_LIBCPP_INLINE_VISIBILITY
@@ -555,7 +551,7 @@ protected:
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 __rebind_alloc<__alloc_traits, __node> __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;
@@ -566,7 +562,7 @@ protected:
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 __rebind_alloc<__alloc_traits, __node_base> __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 "
@@ -845,6 +841,10 @@ public:
typedef void __remove_return_type;
#endif
+ static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
_LIBCPP_INLINE_VISIBILITY
list()
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
@@ -1063,7 +1063,7 @@ public:
__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>()); }
+ __remove_return_type unique() { return unique(__equal_to()); }
template <class _BinaryPred>
__remove_return_type unique(_BinaryPred __binary_pred);
_LIBCPP_INLINE_VISIBILITY
@@ -2362,6 +2362,25 @@ inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _ValueT>
+using list = std::list<_ValueT, polymorphic_allocator<_ValueT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <atomic>
+# include <concepts>
+# include <functional>
+# include <iosfwd>
+# include <iterator>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_LIST
diff --git a/libcxx/include/locale b/libcxx/include/locale
index b01c66d0430f..874866f69822 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -201,19 +201,18 @@ template <class charT> class messages_byname;
#include <__iterator/istreambuf_iterator.h>
#include <__iterator/ostreambuf_iterator.h>
#include <__locale>
-#include <cstdarg> // TODO: Remove this include
+#include <__memory/unique_ptr.h>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ios>
#include <limits>
-#include <memory>
+#include <new>
#include <streambuf>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-#endif
+// TODO: Fix __bsd_locale_defaults.h
+// NOLINTBEGIN(libcpp-robust-against-adl)
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't.
@@ -269,7 +268,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// 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
+_LIBCPP_HIDE_FROM_ABI
_ForwardIterator
__scan_keyword(_InputIterator& __b, _InputIterator __e,
_ForwardIterator __kb, _ForwardIterator __ke,
@@ -450,8 +449,8 @@ 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);
+ std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
+ const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
__thousands_sep = __np.thousands_sep();
return __np.grouping();
}
@@ -463,8 +462,8 @@ __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT&
_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);
+ std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
+ const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
__decimal_point = __np.decimal_point();
__thousands_sep = __np.thousands_sep();
return __np.grouping();
@@ -498,7 +497,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*&
}
return 0;
}
- ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms;
+ ptrdiff_t __f = std::find(__atoms, __atoms + 26, __ct) - __atoms;
if (__f >= 24)
return -1;
switch (__base)
@@ -551,13 +550,13 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
}
return 0;
}
- ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms;
+ ptrdiff_t __f = std::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))
+ if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp)))
{
*__a_end++ = __x;
return 0;
@@ -566,9 +565,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
}
if (__x == 'x' || __x == 'X')
__exp = 'P';
- else if ((__x & 0x5F) == __exp)
+ else if (std::toupper(__x) == __exp)
{
- __exp |= (char) 0x80;
+ __exp = std::tolower(__exp);
if (__in_units)
{
__in_units = false;
@@ -681,8 +680,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~num_get() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {}
template <class _Fp>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
@@ -751,17 +749,17 @@ locale::id
num_get<_CharT, _InputIterator>::id;
template <class _Tp>
-_LIBCPP_HIDDEN _Tp
+_LIBCPP_HIDE_FROM_ABI _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;
+ __libcpp_remove_reference_t<decltype(errno)> __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;
+ __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
if (__p2 != __a_end)
@@ -786,7 +784,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
}
template <class _Tp>
-_LIBCPP_HIDDEN _Tp
+_LIBCPP_HIDE_FROM_ABI _Tp
__num_get_unsigned_integral(const char* __a, const char* __a_end,
ios_base::iostate& __err, int __base)
{
@@ -797,11 +795,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
__err = ios_base::failbit;
return 0;
}
- typename remove_reference<decltype(errno)>::type __save_errno = errno;
+ __libcpp_remove_reference_t<decltype(errno)> __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;
+ __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
if (__p2 != __a_end)
@@ -845,17 +843,17 @@ long double __do_strtod<long double>(const char* __a, char** __p2) {
}
template <class _Tp>
-_LIBCPP_HIDDEN
+_LIBCPP_HIDE_FROM_ABI
_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;
+ __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
errno = 0;
char *__p2;
- _Tp __ld = __do_strtod<_Tp>(__a, &__p2);
- typename remove_reference<decltype(errno)>::type __current_errno = errno;
+ _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
+ __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
if (__p2 != __a_end)
@@ -897,8 +895,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
}
return __b;
}
- const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__iob.getloc());
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc());
+ const numpunct<_CharT>& __np = std::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,
@@ -955,7 +953,7 @@ num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
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);
+ __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
// Digit grouping checked
__check_grouping(__grouping, __g, __g_end, __err);
// EOF checked
@@ -1012,7 +1010,7 @@ num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
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);
+ __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
// Digit grouping checked
__check_grouping(__grouping, __g, __g_end, __err);
// EOF checked
@@ -1067,7 +1065,7 @@ num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_typ
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);
+ __v = std::__num_get_float<_Fp>(__a, __a_end, __err);
// Digit grouping checked
__check_grouping(__grouping, __g, __g_end, __err);
// EOF checked
@@ -1089,8 +1087,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
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);
+ std::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];
@@ -1157,8 +1155,8 @@ __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);
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
+ const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
string __grouping = __npt.grouping();
if (__grouping.empty())
{
@@ -1177,7 +1175,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
*__oe++ = __ct.widen(*__nf++);
*__oe++ = __ct.widen(*__nf++);
}
- reverse(__nf, __ne);
+ std::reverse(__nf, __ne);
_CharT __thousands_sep = __npt.thousands_sep();
unsigned __dc = 0;
unsigned __dg = 0;
@@ -1194,7 +1192,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
*__oe++ = __ct.widen(*__p);
++__dc;
}
- reverse(__ob + (__nf - __nb), __oe);
+ std::reverse(__ob + (__nf - __nb), __oe);
}
if (__np == __ne)
__op = __oe;
@@ -1208,8 +1206,8 @@ __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);
+ const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
+ const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
string __grouping = __npt.grouping();
__oe = __ob;
char* __nf = __nb;
@@ -1238,7 +1236,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
}
else
{
- reverse(__nf, __ns);
+ std::reverse(__nf, __ns);
_CharT __thousands_sep = __npt.thousands_sep();
unsigned __dc = 0;
unsigned __dg = 0;
@@ -1254,7 +1252,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
*__oe++ = __ct.widen(*__p);
++__dc;
}
- reverse(__ob + (__nf - __nb), __oe);
+ std::reverse(__ob + (__nf - __nb), __oe);
}
for (__nf = __ns; __nf < __ne; ++__nf)
{
@@ -1352,8 +1350,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~num_put() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {}
virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
bool __v) const;
@@ -1390,7 +1387,7 @@ locale::id
num_put<_CharT, _OutputIterator>::id;
template <class _CharT, class _OutputIterator>
-_LIBCPP_HIDDEN
+_LIBCPP_HIDE_FROM_ABI
_OutputIterator
__pad_and_output(_OutputIterator __s,
const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
@@ -1413,7 +1410,7 @@ __pad_and_output(_OutputIterator __s,
}
template <class _CharT, class _Traits>
-_LIBCPP_HIDDEN
+_LIBCPP_HIDE_FROM_ABI
ostreambuf_iterator<_CharT, _Traits>
__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
@@ -1465,7 +1462,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
{
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());
+ const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc());
typedef typename numpunct<char_type>::string_type string_type;
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
string_type __tmp(__v ? __np.truename() : __np.falsename());
@@ -1511,7 +1508,7 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
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);
+ return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
}
template <class _CharT, class _OutputIterator>
@@ -1599,7 +1596,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
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);
+ __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
return __s;
}
@@ -1634,7 +1631,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
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());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
__ct.widen(__nar, __ne, __o);
__oe = __o + (__ne - __nar);
if (__np == __ne)
@@ -1643,7 +1640,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
__op = __o + (__np - __nar);
// [__o, __oe) contains wide number
// Stage 3 & 4
- return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+ return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
}
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
@@ -1652,7 +1649,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
#endif
template <class _CharT, class _InputIterator>
-_LIBCPP_HIDDEN
+_LIBCPP_HIDE_FROM_ABI
int
__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)
@@ -1798,8 +1795,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~time_get() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {}
virtual dateorder do_date_order() const;
virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob,
@@ -1930,7 +1926,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
__m = __t;
else
@@ -1944,7 +1940,7 @@ time_get<_CharT, _InputIterator>::__get_year(int& __y,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
if (!(__err & ios_base::failbit))
{
if (__t < 69)
@@ -1962,7 +1958,7 @@ time_get<_CharT, _InputIterator>::__get_year4(int& __y,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
if (!(__err & ios_base::failbit))
__y = __t - 1900;
}
@@ -1974,7 +1970,7 @@ time_get<_CharT, _InputIterator>::__get_hour(int& __h,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
if (!(__err & ios_base::failbit) && __t <= 23)
__h = __t;
else
@@ -1988,7 +1984,7 @@ time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
__h = __t;
else
@@ -2002,7 +1998,7 @@ time_get<_CharT, _InputIterator>::__get_minute(int& __m,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
if (!(__err & ios_base::failbit) && __t <= 59)
__m = __t;
else
@@ -2016,7 +2012,7 @@ time_get<_CharT, _InputIterator>::__get_second(int& __s,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
if (!(__err & ios_base::failbit) && __t <= 60)
__s = __t;
else
@@ -2030,7 +2026,7 @@ time_get<_CharT, _InputIterator>::__get_weekday(int& __w,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 1);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1);
if (!(__err & ios_base::failbit) && __t <= 6)
__w = __t;
else
@@ -2044,7 +2040,7 @@ time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,
ios_base::iostate& __err,
const ctype<char_type>& __ct) const
{
- int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 3);
+ int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3);
if (!(__err & ios_base::failbit) && __t <= 365)
__d = __t;
else
@@ -2109,7 +2105,7 @@ time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,
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());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
__err = ios_base::goodbit;
while (__fmtb != __fmte && __err == ios_base::goodbit)
{
@@ -2196,7 +2192,7 @@ time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,
ios_base::iostate& __err,
tm* __tm) const
{
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
__get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
return __b;
}
@@ -2208,7 +2204,7 @@ time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,
ios_base::iostate& __err,
tm* __tm) const
{
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
__get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
return __b;
}
@@ -2220,7 +2216,7 @@ time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,
ios_base::iostate& __err,
tm* __tm) const
{
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
__get_year(__tm->tm_year, __b, __e, __err, __ct);
return __b;
}
@@ -2233,7 +2229,7 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
char __fmt, char) const
{
__err = ios_base::goodbit;
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
switch (__fmt)
{
case 'a':
@@ -2392,7 +2388,9 @@ extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_
/**/
_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
+#endif
#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
@@ -2416,26 +2414,17 @@ public:
__time_get_storage<_CharT>(__nm) {}
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~time_get_byname() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {}
- _LIBCPP_INLINE_VISIBILITY
- virtual dateorder do_date_order() const {return this->__do_date_order();}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override {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_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override {return this->__weeks_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override {return this->__months_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override {return this->__am_pm_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override {return this->__c_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override {return this->__r_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override {return this->__x_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override {return this->__X_;}
};
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
@@ -2453,8 +2442,10 @@ protected:
~__time_put();
void __do_put(char* __nb, char*& __ne, const tm* __tm,
char __fmt, char __mod) const;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
char __fmt, char __mod) const;
+#endif
};
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
@@ -2483,8 +2474,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~time_put() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {}
virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
char __fmt, char __mod) const;
@@ -2509,7 +2499,7 @@ time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,
const char_type* __pb,
const char_type* __pe) const
{
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
for (; __pb != __pe; ++__pb)
{
if (__ct.narrow(*__pb, 0) == '%')
@@ -2572,8 +2562,7 @@ public:
: time_put<_CharT, _OutputIterator>(__nm, __refs) {}
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~time_put_byname() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {}
};
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
@@ -2621,8 +2610,7 @@ public:
static const bool intl = _International;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~moneypunct() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {}
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();}
@@ -2672,18 +2660,17 @@ public:
: 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_;}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {}
+
+ char_type do_decimal_point() const override {return __decimal_point_;}
+ char_type do_thousands_sep() const override {return __thousands_sep_;}
+ string do_grouping() const override {return __grouping_;}
+ string_type do_curr_symbol() const override {return __curr_symbol_;}
+ string_type do_positive_sign() const override {return __positive_sign_;}
+ string_type do_negative_sign() const override {return __negative_sign_;}
+ int do_frac_digits() const override {return __frac_digits_;}
+ pattern do_pos_format() const override {return __pos_format_;}
+ pattern do_neg_format() const override {return __neg_format_;}
private:
char_type __decimal_point_;
@@ -2740,7 +2727,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
if (__intl)
{
const moneypunct<char_type, true>& __mp =
- use_facet<moneypunct<char_type, true> >(__loc);
+ std::use_facet<moneypunct<char_type, true> >(__loc);
__pat = __mp.neg_format();
__nsn = __mp.negative_sign();
__psn = __mp.positive_sign();
@@ -2753,7 +2740,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
else
{
const moneypunct<char_type, false>& __mp =
- use_facet<moneypunct<char_type, false> >(__loc);
+ std::use_facet<moneypunct<char_type, false> >(__loc);
__pat = __mp.neg_format();
__nsn = __mp.negative_sign();
__psn = __mp.positive_sign();
@@ -2801,9 +2788,7 @@ public:
static locale::id id;
protected:
-
- _LIBCPP_INLINE_VISIBILITY
- ~money_get() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {}
virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
ios_base& __iob, ios_base::iostate& __err,
@@ -2828,7 +2813,7 @@ money_get<_CharT, _InputIterator>::id;
_LIBCPP_FUNC_VIS void __do_nothing(void*);
template <class _Tp>
-_LIBCPP_HIDDEN
+_LIBCPP_HIDE_FROM_ABI
void
__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
{
@@ -2839,7 +2824,7 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
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);
+ _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);
if (__t == 0)
__throw_bad_alloc();
if (__owns)
@@ -2954,7 +2939,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
++__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(),
+ !std::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
@@ -2985,14 +2970,14 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
if (__ct.is(ctype_base::digit, __c))
{
if (__wn == __we)
- __double_or_nothing(__wb, __wn, __we);
+ std::__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);
+ std::__double_or_nothing(__gb, __gn, __ge);
*__gn++ = __ng;
__ng = 0;
}
@@ -3002,7 +2987,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
if (__gb.get() != __gn && __ng > 0)
{
if (__gn == __ge)
- __double_or_nothing(__gb, __gn, __ge);
+ std::__double_or_nothing(__gb, __gn, __ge);
*__gn++ = __ng;
}
if (__fd > 0)
@@ -3020,7 +3005,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
return false;
}
if (__wn == __we)
- __double_or_nothing(__wb, __wn, __we);
+ std::__double_or_nothing(__wb, __wn, __we);
*__wn++ = *__b;
}
}
@@ -3070,7 +3055,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
char_type* __wn;
char_type* __we = __wbuf + __bz;
locale __loc = __iob.getloc();
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
bool __neg = false;
if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
__wb, __wn, __we))
@@ -3091,7 +3076,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
if (__neg)
*__nc++ = '-';
for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
- *__nc = __src[find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
+ *__nc = __src[std::find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
*__nc = char();
if (sscanf(__nbuf, "%Lf", &__v) != 1)
__throw_runtime_error("money_get error");
@@ -3114,7 +3099,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
char_type* __wn;
char_type* __we = __wbuf + __bz;
locale __loc = __iob.getloc();
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
bool __neg = false;
if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
__wb, __wn, __we))
@@ -3176,7 +3161,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
if (__intl)
{
const moneypunct<char_type, true>& __mp =
- use_facet<moneypunct<char_type, true> >(__loc);
+ std::use_facet<moneypunct<char_type, true> >(__loc);
if (__neg)
{
__pat = __mp.neg_format();
@@ -3196,7 +3181,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
else
{
const moneypunct<char_type, false>& __mp =
- use_facet<moneypunct<char_type, false> >(__loc);
+ std::use_facet<moneypunct<char_type, false> >(__loc);
if (__neg)
{
__pat = __mp.neg_format();
@@ -3296,7 +3281,7 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
}
}
// reverse it
- reverse(__t, __me);
+ std::reverse(__t, __me);
}
break;
}
@@ -3347,8 +3332,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~money_put() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {}
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
char_type __fl, long double __units) const;
@@ -3389,7 +3373,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
}
// gather info
locale __loc = __iob.getloc();
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
__ct.widen(__bb, __bb + __n, __db);
bool __neg = __n > 0 && __bb[0] == '-';
money_base::pattern __pat;
@@ -3421,7 +3405,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
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);
+ return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
}
template <class _CharT, class _OutputIterator>
@@ -3432,7 +3416,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
{
// gather info
locale __loc = __iob.getloc();
- const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+ const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
money_base::pattern __pat;
char_type __dp;
@@ -3463,7 +3447,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
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);
+ return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
}
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
@@ -3516,8 +3500,7 @@ public:
static locale::id id;
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~messages() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {}
virtual catalog do_open(const basic_string<char>&, const locale&) const;
virtual string_type do_get(catalog, int __set, int __msgid,
@@ -3551,7 +3534,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
{
#ifdef _LIBCPP_HAS_CATOPEN
string __ndflt;
- __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
+ __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__ndflt),
__dflt.c_str(),
__dflt.c_str() + __dflt.size());
if (__c != -1)
@@ -3559,7 +3542,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
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),
+ __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__w),
__n, __n + _VSTD::strlen(__n));
return __w;
#else // !_LIBCPP_HAS_CATOPEN
@@ -3606,8 +3589,7 @@ public:
: messages<_CharT>(__refs) {}
protected:
- _LIBCPP_INLINE_VISIBILITY
- ~messages_byname() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {}
};
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
@@ -4007,7 +3989,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
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);
+ const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
int_type __c = traits_type::eof();
if (this->gptr() == this->egptr())
{
@@ -4026,9 +4008,11 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
}
else
{
- _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
- if (__extbufend_ != __extbufnext_)
+ if (__extbufend_ != __extbufnext_) {
+ _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
+ _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
_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),
@@ -4276,7 +4260,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
{
if (this->gptr() != this->egptr())
{
- reverse(this->gptr(), this->egptr());
+ std::reverse(this->gptr(), this->egptr());
codecvt_base::result __r;
const char_type* __e = this->gptr();
char* __extbe;
@@ -4369,4 +4353,16 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+// NOLINTEND(libcpp-robust-against-adl)
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <cstdarg>
+# include <iterator>
+# include <stdexcept>
+# include <type_traits>
+# include <typeinfo>
+#endif
+
#endif // _LIBCPP_LOCALE
diff --git a/libcxx/include/locale.h b/libcxx/include/locale.h
index 17c0a705a009..3fb812035a52 100644
--- a/libcxx/include/locale.h
+++ b/libcxx/include/locale.h
@@ -43,6 +43,8 @@ Functions:
# pragma GCC system_header
#endif
-#include_next <locale.h>
+#if __has_include_next(<locale.h>)
+# include_next <locale.h>
+#endif
#endif // _LIBCPP_LOCALE_H
diff --git a/libcxx/include/map b/libcxx/include/map
index e1d5fa8a25d8..9cf47b245a02 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -538,20 +538,18 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
+#include <__memory/allocator.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__node_handle>
#include <__tree>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
+#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
-#include <memory>
+#include <tuple>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-# include <iterator>
-# include <utility>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -619,46 +617,46 @@ public:
template <class _Key, class _CP, class _Compare>
class __map_value_compare<_Key, _CP, _Compare, false>
{
- _Compare comp;
+ _Compare __comp_;
public:
_LIBCPP_INLINE_VISIBILITY
__map_value_compare()
_NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
- : comp() {}
+ : __comp_() {}
_LIBCPP_INLINE_VISIBILITY
__map_value_compare(_Compare __c)
_NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
- : comp(__c) {}
+ : __comp_(__c) {}
_LIBCPP_INLINE_VISIBILITY
- const _Compare& key_comp() const _NOEXCEPT {return comp;}
+ 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);}
+ {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);}
+ {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);}
+ {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);
+ 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);}
+ {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);}
+ {return __comp_(__x.__get_value().first, __y);}
#endif
};
@@ -738,16 +736,16 @@ struct _LIBCPP_STANDALONE_DEBUG __value_type
typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
private:
- value_type __cc;
+ value_type __cc_;
public:
_LIBCPP_INLINE_VISIBILITY
value_type& __get_value()
{
#if _LIBCPP_STD_VER > 14
- return *_VSTD::launder(_VSTD::addressof(__cc));
+ return *_VSTD::launder(_VSTD::addressof(__cc_));
#else
- return __cc;
+ return __cc_;
#endif
}
@@ -755,9 +753,9 @@ public:
const value_type& __get_value() const
{
#if _LIBCPP_STD_VER > 14
- return *_VSTD::launder(_VSTD::addressof(__cc));
+ return *_VSTD::launder(_VSTD::addressof(__cc_));
#else
- return __cc;
+ return __cc_;
#endif
}
@@ -818,13 +816,13 @@ struct __value_type
typedef pair<const key_type, mapped_type> value_type;
private:
- value_type __cc;
+ value_type __cc_;
public:
_LIBCPP_INLINE_VISIBILITY
- value_type& __get_value() { return __cc; }
+ value_type& __get_value() { return __cc_; }
_LIBCPP_INLINE_VISIBILITY
- const value_type& __get_value() const { return __cc; }
+ const value_type& __get_value() const { return __cc_; }
private:
__value_type();
@@ -1001,12 +999,15 @@ 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 __rebind_alloc<allocator_traits<allocator_type>, __value_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;
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
__base __tree_;
public:
@@ -1778,12 +1779,15 @@ 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 __rebind_alloc<allocator_traits<allocator_type>, __value_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;
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
__base __tree_;
public:
@@ -2335,4 +2339,23 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
+using map = std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
+
+template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
+using multimap = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <iterator>
+# include <utility>
+#endif
+
#endif // _LIBCPP_MAP
diff --git a/libcxx/include/math.h b/libcxx/include/math.h
index 0ec584af9dbe..a23d1ff3ed37 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -297,7 +297,9 @@ long double truncl(long double x);
# pragma GCC system_header
#endif
-#include_next <math.h>
+# if __has_include_next(<math.h>)
+# include_next <math.h>
+# endif
#ifdef __cplusplus
@@ -305,479 +307,237 @@ long double truncl(long double x);
// back to C++ linkage before including these C++ headers.
extern "C++" {
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/promote.h>
#include <limits>
#include <stdlib.h>
-#include <type_traits>
-// signbit
-#ifdef signbit
+# ifdef fpclassify
+# undef fpclassify
+# endif
-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
-}
+# ifdef signbit
+# undef signbit
+# endif
-#undef signbit
+# ifdef isfinite
+# undef isfinite
+# endif
-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);
-}
+# ifdef isinf
+# undef isinf
+# endif
-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; }
+# ifdef isnan
+# undef isnan
+# endif
-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));
-}
+# ifdef isnormal
+# undef isnormal
+# endif
-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; }
+# ifdef isgreater
+# undef isgreater
+# endif
-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; }
+# ifdef isgreaterequal
+# undef isgreaterequal
+# endif
+
+# ifdef isless
+# undef isless
+# endif
-#endif // signbit
+# ifdef islessequal
+# undef islessequal
+# endif
-// fpclassify
+# ifdef islessgreater
+# undef islessgreater
+# endif
-#ifdef fpclassify
+# ifdef isunordered
+# undef isunordered
+# endif
-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
-}
+// signbit
-#undef fpclassify
+template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
+ return __builtin_signbit(__x);
+}
-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, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
+ return __x < 0;
}
-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; }
+template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
+ return false;
+}
-#elif defined(_LIBCPP_MSVCRT)
+// fpclassify
-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, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
+ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __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; }
+template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
+ return __x == 0 ? FP_ZERO : FP_NORMAL;
+}
-#endif // fpclassify
+// The MSVC runtime already provides these functions as templates
+#ifndef _LIBCPP_MSVCRT
// 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
+template <class _A1,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
+ return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
}
-#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,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
+ return true;
}
-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,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
+ return __builtin_isinf((typename std::__promote<_A1>::type)__x);
+}
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
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
+ typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
+ isinf(_A1) _NOEXCEPT {
+ return false;
}
-#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);
+# ifdef _LIBCPP_PREFERRED_OVERLOAD
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
+ return __builtin_isinf(__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; }
-
-#ifdef _LIBCPP_PREFERRED_OVERLOAD
-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
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
+ return __builtin_isinf(__x);
+}
-#endif // isinf
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
+ return __builtin_isinf(__x);
+}
+# endif
// 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
+template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
}
-#undef isnan
+template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
+ return false;
+}
-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);
+# ifdef _LIBCPP_PREFERRED_OVERLOAD
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
}
-template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if<std::is_integral<_A1>::value, bool>::type
-isnan(_A1) _NOEXCEPT
-{ return false; }
-
-#ifdef _LIBCPP_PREFERRED_OVERLOAD
-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
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
+}
-#endif // isnan
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
+}
+# endif
// 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
+template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
+ return __builtin_isnormal(__x);
}
-#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, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
+ return __x != 0;
}
-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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_isgreater((type)__x, (type)__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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_isgreaterequal((type)__x, (type)__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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_isless((type)__x, (type)__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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_islessequal((type)__x, (type)__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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_islessgreater((type)__x, (type)__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);
+template <class _A1,
+ class _A2,
+ std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
+ typedef typename std::__promote<_A1, _A2>::type type;
+ return __builtin_isunordered((type)__x, (type)__y);
}
-#endif // isunordered
+#endif // _LIBCPP_MSVCRT
// abs
//
@@ -787,497 +547,633 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
//
// handled in stdlib.h
+// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
+// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
+// templates. Functions are preferred over function templates during overload resolution, which means that our overload
+// will only be selected when the C library doesn't provide one.
+
// acos
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
+ return __builtin_acos(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
+acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);}
// asin
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
+ return __builtin_asin(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
+asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);}
// atan
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
+ return __builtin_atan(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
+atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);}
// atan2
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
+ return __builtin_atan2(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);}
# endif
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+atan2(_A1 __y, _A2 __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);
+ return ::atan2((__result_type)__y, (__result_type)__x);
}
// ceil
# if !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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
+ return __builtin_ceil(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
+ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);}
// cos
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
+ return __builtin_cos(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
+cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);}
// cosh
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
+ return __builtin_cosh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
+cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);}
// exp
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
+ return __builtin_exp(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
+exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);}
// fabs
# if !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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
+ return __builtin_fabs(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
+fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);}
// floor
# if !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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
+ return __builtin_floor(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
+floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);}
// fmod
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT {
+ return __builtin_fmod(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);}
# endif
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+fmod(_A1 __x, _A2 __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);
+ return ::fmod((__result_type)__x, (__result_type)__y);
}
// frexp
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
+ return __builtin_frexp(__x, __e);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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);}
+frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);}
// ldexp
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
+ return __builtin_ldexp(__x, __e);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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);}
+ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);}
// log
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT {
+ return __builtin_log(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
+log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);}
// log10
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
+
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT {
+ return __builtin_log10(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
+log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);}
// modf
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT {
+ return __builtin_modf(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);}
# endif
// pow
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
+ return __builtin_pow(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);}
# endif
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+pow(_A1 __x, _A2 __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);
+ return ::pow((__result_type)__x, (__result_type)__y);
}
// sin
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
+ return __builtin_sin(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);}
#endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
+sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);}
// sinh
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
+ return __builtin_sinh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
+sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);}
// sqrt
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT {
+ return __builtin_sqrt(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
+sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);}
// tan
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
+ return __builtin_tan(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
+tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);}
// tanh
# if !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);}
+inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
+ return __builtin_tanh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);}
# endif
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
+tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
+ return __builtin_acosh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
+acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
+ return __builtin_asinh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
+asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
+ return __builtin_atanh(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
+atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
+ return __builtin_cbrt(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
+cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__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
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
+ return ::__builtin_copysignf(__x, __y);
}
-#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
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
+ return ::__builtin_copysignl(__x, __y);
}
template <class _A1, class _A2>
-#if __has_builtin(__builtin_copysign)
-_LIBCPP_CONSTEXPR
-#endif
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
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
+ copysign(_A1 __x, _A2 __y) _NOEXCEPT {
+ return ::__builtin_copysign(__x, __y);
}
-inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
- return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
-}
+// erf
-inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
- return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
-}
+inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
-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);
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
+ return __builtin_erf(__x);
}
-// 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);}
+inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
+erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
+ return __builtin_erfc(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
+erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
+ return __builtin_exp2(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
+exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
+ return __builtin_expm1(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
+expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
+ return __builtin_fdim(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+fdim(_A1 __x, _A2 __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);
+ return ::fdim((__result_type)__x, (__result_type)__y);
}
// fma
-inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT
+inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __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
+ return __builtin_fmaf(__x, __y, __z);
+}
+
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
+ return __builtin_fma(__x, __y, __z);
}
-inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT
+
+inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __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
+ return __builtin_fmal(__x, __y, __z);
}
template <class _A1, class _A2, class _A3>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::__enable_if_t
<
std::is_arithmetic<_A1>::value &&
@@ -1285,462 +1181,512 @@ typename std::__enable_if_t
std::is_arithmetic<_A3>::value,
std::__promote<_A1, _A2, _A3>
>::type
-fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
+fma(_A1 __x, _A2 __y, _A3 __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
+ return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
}
// 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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
+ return __builtin_fmax(__x, __y);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
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
+fmax(_A1 __x, _A2 __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);
+ return ::fmax((__result_type)__x, (__result_type)__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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
+ return __builtin_fmin(__x, __y);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
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
+fmin(_A1 __x, _A2 __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);
+ return ::fmin((__result_type)__x, (__result_type)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
+ return __builtin_hypot(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+hypot(_A1 __x, _A2 __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);
+ return ::hypot((__result_type)__x, (__result_type)__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);}
+inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT {
+ return __builtin_ilogb(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, int>::type
-ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
+ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
+ return __builtin_lgamma(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
+lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);}
// llrint
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT
+inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llrintf)
- return __builtin_llrintf(__lcpp_x);
-#else
- return ::llrintf(__lcpp_x);
-#endif
+ return __builtin_llrintf(__x);
+}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT {
+ return __builtin_llrint(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT
+
+inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llrintl)
- return __builtin_llrintl(__lcpp_x);
-#else
- return ::llrintl(__lcpp_x);
-#endif
+ return __builtin_llrintl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, long long>::type
-llrint(_A1 __lcpp_x) _NOEXCEPT
+llrint(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llrint)
- return __builtin_llrint((double)__lcpp_x);
-#else
- return ::llrint((double)__lcpp_x);
-#endif
+ return __builtin_llrint((double)__x);
}
// llround
-inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT
+inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llroundf)
- return __builtin_llroundf(__lcpp_x);
-#else
- return ::llroundf(__lcpp_x);
-#endif
+ return __builtin_llroundf(__x);
+}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT {
+ return __builtin_llround(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT
+
+inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llroundl)
- return __builtin_llroundl(__lcpp_x);
-#else
- return ::llroundl(__lcpp_x);
-#endif
+ return __builtin_llroundl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, long long>::type
-llround(_A1 __lcpp_x) _NOEXCEPT
+llround(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_llround)
- return __builtin_llround((double)__lcpp_x);
-#else
- return ::llround((double)__lcpp_x);
-#endif
+ return __builtin_llround((double)__x);
}
// 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);}
+inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT {
+ return __builtin_log1p(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
+log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT {
+ return __builtin_log2(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
+log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT {
+ return __builtin_logb(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
+logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);}
// lrint
-inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT
+inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lrintf)
- return __builtin_lrintf(__lcpp_x);
-#else
- return ::lrintf(__lcpp_x);
-#endif
+ return __builtin_lrintf(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT {
+ return __builtin_lrint(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lrintl)
- return __builtin_lrintl(__lcpp_x);
-#else
- return ::lrintl(__lcpp_x);
-#endif
+ return __builtin_lrintl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, long>::type
-lrint(_A1 __lcpp_x) _NOEXCEPT
+lrint(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lrint)
- return __builtin_lrint((double)__lcpp_x);
-#else
- return ::lrint((double)__lcpp_x);
-#endif
+ return __builtin_lrint((double)__x);
}
// lround
-inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT
+inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lroundf)
- return __builtin_lroundf(__lcpp_x);
-#else
- return ::lroundf(__lcpp_x);
-#endif
+ return __builtin_lroundf(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT {
+ return __builtin_lround(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lroundl)
- return __builtin_lroundl(__lcpp_x);
-#else
- return ::lroundl(__lcpp_x);
-#endif
+ return __builtin_lroundl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, long>::type
-lround(_A1 __lcpp_x) _NOEXCEPT
+lround(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_lround)
- return __builtin_lround((double)__lcpp_x);
-#else
- return ::lround((double)__lcpp_x);
-#endif
+ return __builtin_lround((double)__x);
}
// 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);}
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
+ return __builtin_nearbyint(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
+nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT {
+ return __builtin_nextafter(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+nextafter(_A1 __x, _A2 __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);
+ return ::nextafter((__result_type)__x, (__result_type)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT {
+ return __builtin_nexttoward(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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);}
+nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __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);}
+inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT {
+ return __builtin_remainder(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+remainder(_A1 __x, _A2 __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);
+ return ::remainder((__result_type)__x, (__result_type)__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);}
+inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT {
+ return __builtin_remquo(__x, __y, __z);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);}
template <class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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
+remquo(_A1 __x, _A2 __y, int* __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);
+ return ::remquo((__result_type)__x, (__result_type)__y, __z);
}
// rint
-inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_rintf)
- return __builtin_rintf(__lcpp_x);
-#else
- return ::rintf(__lcpp_x);
-#endif
+ return __builtin_rintf(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
+ return __builtin_rint(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_rintl)
- return __builtin_rintl(__lcpp_x);
-#else
- return ::rintl(__lcpp_x);
-#endif
+ return __builtin_rintl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-rint(_A1 __lcpp_x) _NOEXCEPT
+rint(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_rint)
- return __builtin_rint((double)__lcpp_x);
-#else
- return ::rint((double)__lcpp_x);
-#endif
+ return __builtin_rint((double)__x);
}
// round
-inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_round)
- return __builtin_round(__lcpp_x);
-#else
- return ::round(__lcpp_x);
-#endif
+ return __builtin_round(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
+ return __builtin_round(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_roundl)
- return __builtin_roundl(__lcpp_x);
-#else
- return ::roundl(__lcpp_x);
-#endif
+ return __builtin_roundl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-round(_A1 __lcpp_x) _NOEXCEPT
+round(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_round)
- return __builtin_round((double)__lcpp_x);
-#else
- return ::round((double)__lcpp_x);
-#endif
+ return __builtin_round((double)__x);
}
// 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);}
+inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
+ return __builtin_scalbln(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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);}
+scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __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);}
+inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
+ return __builtin_scalbn(__x, __y);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
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);}
+scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __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);}
+inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
+
+template <class = int>
+_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
+ return __builtin_tgamma(__x);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
+tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);}
// trunc
-inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_trunc)
- return __builtin_trunc(__lcpp_x);
-#else
- return ::trunc(__lcpp_x);
-#endif
+ return __builtin_trunc(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT
+
+template <class = int>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
+ return __builtin_trunc(__x);
+}
+
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_truncl)
- return __builtin_truncl(__lcpp_x);
-#else
- return ::truncl(__lcpp_x);
-#endif
+ return __builtin_truncl(__x);
}
template <class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-trunc(_A1 __lcpp_x) _NOEXCEPT
+trunc(_A1 __x) _NOEXCEPT
{
-#if __has_builtin(__builtin_trunc)
- return __builtin_trunc((double)__lcpp_x);
-#else
- return ::trunc((double)__lcpp_x);
-#endif
+ return __builtin_trunc((double)__x);
}
} // extern "C++"
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 56f8159fbd44..0a7787acf1a8 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -406,16 +406,17 @@ template <class T>
struct default_delete
{
constexpr default_delete() noexcept = default;
- template <class U> default_delete(const default_delete<U>&) noexcept;
+ template <class U> constexpr default_delete(const default_delete<U>&) noexcept; // constexpr since C++23
- void operator()(T*) const noexcept;
+ constexpr void operator()(T*) const noexcept; // constexpr since C++23
};
template <class T>
struct default_delete<T[]>
{
constexpr default_delete() noexcept = default;
- void operator()(T*) const noexcept;
+ template <class U> constexpr default_delete(const default_delete <U[]>&) noexcept; // constexpr since C++23
+ constexpr void operator()(T*) const noexcept; // constexpr since C++23
template <class U> void operator()(U*) const = delete;
};
@@ -429,36 +430,37 @@ public:
// 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() { }
+ constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
+ constexpr unique_ptr(pointer p, see below d1) noexcept; // constexpr since C++23
+ constexpr unique_ptr(pointer p, see below d2) noexcept; // constexpr since C++23
+ constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
+ constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
template <class U, class E>
- unique_ptr(unique_ptr<U, E>&& u) noexcept;
+ constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept; // constexpr since C++23
template <class U>
- unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
+ unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
// destructor
- ~unique_ptr();
+ constexpr ~unique_ptr(); // constexpr since C++23
// 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;
+ constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
+ template <class U, class E>
+ constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; // constexpr since C++23
+ constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23
// 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;
+ typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23
+ constexpr pointer operator->() const noexcept; // constexpr since C++23
+ constexpr pointer get() const noexcept; // constexpr since C++23
+ constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
+ constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
+ constexpr explicit operator bool() const noexcept; // constexpr since C++23
// modifiers
- pointer release() noexcept;
- void reset(pointer p = pointer()) noexcept;
- void swap(unique_ptr& u) noexcept;
+ constexpr pointer release() noexcept; // constexpr since C++23
+ constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
+ constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23
};
template <class T, class D>
@@ -471,41 +473,45 @@ public:
// 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() { }
+ constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
+ constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
+ constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
+ constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
+ template <class U, class E>
+ constexpr unique_ptr(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
+ constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
// destructor
- ~unique_ptr();
+ constexpr ~unique_ptr(); // constexpr since C++23
// assignment
- unique_ptr& operator=(unique_ptr&& u) noexcept;
- unique_ptr& operator=(nullptr_t) noexcept;
+ constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
+ template <class U, class E>
+ constexpr unique_ptr& operator=(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
+ constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23
// 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;
+ constexpr T& operator[](size_t i) const; // constexpr since C++23
+ constexpr pointer get() const noexcept; // constexpr since C++23
+ constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
+ constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
+ constexpr explicit operator bool() const noexcept; // constexpr since C++23
// modifiers
- pointer release() noexcept;
- void reset(pointer p = pointer()) noexcept;
- void reset(nullptr_t) noexcept;
+ constexpr pointer release() noexcept; // constexpr since C++23
+ constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
+ constexpr void reset(nullptr_t) noexcept; // constexpr since C++23
template <class U> void reset(U) = delete;
- void swap(unique_ptr& u) noexcept;
+ constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23
};
template <class T, class D>
- void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
+ constexpr void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; // constexpr since C++23
template <class T1, class D1, class T2, class D2>
- bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+ constexpr bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // constexpr since C++23
template <class T1, class D1, class T2, class D2>
- bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+ bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // removed in C++20
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>
@@ -514,32 +520,42 @@ 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>
+ requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
+ typename unique_ptr<T2, D2>::pointer>
+ compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
+ typename unique_ptr<T2, D2>::pointer>
+ operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // C++20
template <class T, class D>
- bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+ constexpr bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; // constexpr since C++23
template <class T, class D>
- bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+ bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; // removed in C++20
template <class T, class D>
- bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+ bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; // removed in C++20
template <class T, class D>
- bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+ bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; // removed in C++20
template <class T, class D>
- bool operator<(const unique_ptr<T, D>& x, nullptr_t);
+ constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
template <class T, class D>
- bool operator<(nullptr_t, const unique_ptr<T, D>& y);
+ constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
template <class T, class D>
- bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
+ constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
template <class T, class D>
- bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
+ constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
template <class T, class D>
- bool operator>(const unique_ptr<T, D>& x, nullptr_t);
+ constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
template <class T, class D>
- bool operator>(nullptr_t, const unique_ptr<T, D>& y);
+ constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
template <class T, class D>
- bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
+ constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
template <class T, class D>
- bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
+ constexpr bool operator>=(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
+template<class T, class D>
+ requires three_way_comparable<typename unique_ptr<T, D>::pointer>
+ compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
+ constexpr operator<=>(const unique_ptr<T, D>& x, nullptr_t); // C++20, constexpr since C++23
class bad_weak_ptr
: public std::exception
@@ -547,10 +563,19 @@ class bad_weak_ptr
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>
+constexpr unique_ptr<T> make_unique(Args&&... args); // C++14, constexpr since C++23
+template<class T>
+constexpr unique_ptr<T> make_unique(size_t n); // C++14, constexpr since C++23
template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
+template<class T>
+ constexpr unique_ptr<T> make_unique_for_overwrite(); // T is not array, C++20, constexpr since C++23
+template<class T>
+ constexpr unique_ptr<T> make_unique_for_overwrite(size_t n); // T is U[], C++20, constexpr since C++23
+template<class T, class... Args>
+ unspecified make_unique_for_overwrite(Args&&...) = delete; // T is U[N], C++20
+
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);
@@ -617,40 +642,44 @@ shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
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;
+ bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
+template<class T, class U>
+ bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
template<class T, class U>
- bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+ bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
template<class T, class U>
- bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+ bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
template<class T, class U>
- bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+ bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
template<class T, class U>
- bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+ strong_ordering operator<=>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // C++20
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;
+ bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
template <class T>
- bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+ bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
template <class T>
- bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+ bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
template <class T>
- bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+ bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
template <class T>
-bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+ bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
template <class T>
- bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+ bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
template <class T>
- bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+ bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
template <class T>
- bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+ bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
template <class T>
- bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+ bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
template <class T>
- bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+ bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
template <class T>
- bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+ bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
+template<class T>
+ strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept; // C++20
// shared_ptr specialized algorithms:
template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
@@ -696,6 +725,16 @@ template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
template<class T>
+ shared_ptr<T> make_shared_for_overwrite(); // T is not U[], C++20
+template<class T, class A>
+ shared_ptr<T> allocate_shared_for_overwrite(const A& a); // T is not U[], C++20
+
+template<class T>
+ shared_ptr<T> make_shared_for_overwrite(size_t N); // T is U[], C++20
+template<class T, class A>
+ shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // T is U[], C++20
+
+template<class T>
class weak_ptr
{
public:
@@ -841,6 +880,7 @@ template<size_t N, class T>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__memory/addressof.h>
+#include <__memory/align.h>
#include <__memory/allocate_at_least.h>
#include <__memory/allocation_guard.h>
#include <__memory/allocator.h>
@@ -860,162 +900,35 @@ template<size_t N, class T>
#include <__memory/uninitialized_algorithms.h>
#include <__memory/unique_ptr.h>
#include <__memory/uses_allocator.h>
-#include <cstddef>
-#include <cstdint>
-#include <cstring>
-#include <iosfwd>
-#include <new>
-#include <stdexcept>
-#include <tuple>
-#include <type_traits>
-#include <typeinfo>
+#include <__memory/uses_allocator_construction.h>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-# include <utility>
-#endif
-
// standard-mandated includes
+
+// [memory.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-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);
-
-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
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <cstddef>
+# include <cstdint>
+# include <cstring>
+# include <iosfwd>
+# include <iterator>
+# include <new>
+# include <stdexcept>
+# include <tuple>
+# include <type_traits>
+# include <typeinfo>
+# include <utility>
+#endif
+
#endif // _LIBCPP_MEMORY
diff --git a/libcxx/include/memory_resource b/libcxx/include/memory_resource
new file mode 100644
index 000000000000..4b393433696f
--- /dev/null
+++ b/libcxx/include/memory_resource
@@ -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_MEMORY_RESOURCE
+#define _LIBCPP_MEMORY_RESOURCE
+
+/**
+ memory_resource synopsis
+
+// C++17
+
+namespace std::pmr {
+
+ class memory_resource;
+
+ bool operator==(const memory_resource& a,
+ const memory_resource& b) noexcept;
+ bool operator!=(const memory_resource& a,
+ const memory_resource& b) noexcept;
+
+ template <class Tp> class polymorphic_allocator;
+
+ template <class T1, class T2>
+ bool operator==(const polymorphic_allocator<T1>& a,
+ const polymorphic_allocator<T2>& b) noexcept;
+ template <class T1, class T2>
+ bool operator!=(const polymorphic_allocator<T1>& a,
+ const polymorphic_allocator<T2>& b) noexcept;
+
+ // Global memory resources
+ memory_resource* set_default_resource(memory_resource* r) noexcept;
+ memory_resource* get_default_resource() noexcept;
+ memory_resource* new_delete_resource() noexcept;
+ memory_resource* null_memory_resource() noexcept;
+
+ // Pool resource classes
+ struct pool_options;
+ class synchronized_pool_resource;
+ class unsynchronized_pool_resource;
+ class monotonic_buffer_resource;
+
+} // namespace std::pmr
+
+ */
+
+#include <__config>
+#include <__memory_resource/memory_resource.h>
+#include <__memory_resource/monotonic_buffer_resource.h>
+#include <__memory_resource/polymorphic_allocator.h>
+#include <__memory_resource/pool_options.h>
+#include <__memory_resource/synchronized_pool_resource.h>
+#include <__memory_resource/unsynchronized_pool_resource.h>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#endif /* _LIBCPP_MEMORY_RESOURCE */
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 98485bcd93ab..1f1d67dbb7fc 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -59,7 +59,10 @@ module std [system] {
// FIXME: <stdalign.h> is missing.
// <signal.h> provided by C library.
// <stdarg.h> provided by compiler.
- // <stdbool.h> provided by compiler.
+ module stdbool_h {
+ // <stdbool.h>'s __bool_true_false_are_defined macro requires textual inclusion.
+ textual header "stdbool.h"
+ }
module stddef_h {
// <stddef.h>'s __need_* macros require textual inclusion.
textual header "stddef.h"
@@ -248,6 +251,7 @@ module std [system] {
module copy { private header "__algorithm/copy.h" }
module copy_backward { private header "__algorithm/copy_backward.h" }
module copy_if { private header "__algorithm/copy_if.h" }
+ module copy_move_common { private header "__algorithm/copy_move_common.h" }
module copy_n { private header "__algorithm/copy_n.h" }
module count { private header "__algorithm/count.h" }
module count_if { private header "__algorithm/count_if.h" }
@@ -280,7 +284,10 @@ module std [system] {
module is_sorted { private header "__algorithm/is_sorted.h" }
module is_sorted_until { private header "__algorithm/is_sorted_until.h" }
module iter_swap { private header "__algorithm/iter_swap.h" }
- module iterator_operations { private header "__algorithm/iterator_operations.h" }
+ module iterator_operations {
+ private header "__algorithm/iterator_operations.h"
+ export *
+ }
module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" }
module lower_bound { private header "__algorithm/lower_bound.h" }
module make_heap { private header "__algorithm/make_heap.h" }
@@ -310,15 +317,37 @@ module std [system] {
module ranges_adjacent_find { private header "__algorithm/ranges_adjacent_find.h" }
module ranges_all_of { private header "__algorithm/ranges_all_of.h" }
module ranges_any_of { private header "__algorithm/ranges_any_of.h" }
- module ranges_binary_search { private header "__algorithm/ranges_binary_search.h" }
- module ranges_copy { private header "__algorithm/ranges_copy.h" }
- module ranges_copy_backward { private header "__algorithm/ranges_copy_backward.h" }
- module ranges_copy_if { private header "__algorithm/ranges_copy_if.h" }
- module ranges_copy_n { private header "__algorithm/ranges_copy_n.h" }
+ module ranges_binary_search {
+ private header "__algorithm/ranges_binary_search.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_clamp {
+ private header "__algorithm/ranges_clamp.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_copy {
+ private header "__algorithm/ranges_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_copy_backward {
+ private header "__algorithm/ranges_copy_backward.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_copy_if {
+ private header "__algorithm/ranges_copy_if.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_copy_n {
+ private header "__algorithm/ranges_copy_n.h"
+ export algorithm.__algorithm.in_out_result
+ }
module ranges_count { private header "__algorithm/ranges_count.h" }
module ranges_count_if { private header "__algorithm/ranges_count_if.h" }
module ranges_equal { private header "__algorithm/ranges_equal.h" }
- module ranges_equal_range { private header "__algorithm/ranges_equal_range.h" }
+ module ranges_equal_range {
+ private header "__algorithm/ranges_equal_range.h"
+ export functional.__functional.ranges_operations
+ }
module ranges_fill { private header "__algorithm/ranges_fill.h" }
module ranges_fill_n { private header "__algorithm/ranges_fill_n.h" }
module ranges_find { private header "__algorithm/ranges_find.h" }
@@ -326,67 +355,219 @@ module std [system] {
module ranges_find_first_of { private header "__algorithm/ranges_find_first_of.h" }
module ranges_find_if { private header "__algorithm/ranges_find_if.h" }
module ranges_find_if_not { private header "__algorithm/ranges_find_if_not.h" }
- module ranges_for_each { private header "__algorithm/ranges_for_each.h" }
- module ranges_for_each_n { private header "__algorithm/ranges_for_each_n.h" }
+ module ranges_for_each {
+ private header "__algorithm/ranges_for_each.h"
+ export algorithm.__algorithm.in_fun_result
+ }
+ module ranges_for_each_n {
+ private header "__algorithm/ranges_for_each_n.h"
+ export algorithm.__algorithm.in_fun_result
+ }
module ranges_generate { private header "__algorithm/ranges_generate.h" }
module ranges_generate_n { private header "__algorithm/ranges_generate_n.h" }
- module ranges_includes { private header "__algorithm/ranges_includes.h" }
- module ranges_inplace_merge { private header "__algorithm/ranges_inplace_merge.h" }
- module ranges_is_heap { private header "__algorithm/ranges_is_heap.h" }
- module ranges_is_heap_until { private header "__algorithm/ranges_is_heap_until.h" }
+ module ranges_includes {
+ private header "__algorithm/ranges_includes.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_inplace_merge {
+ private header "__algorithm/ranges_inplace_merge.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_is_heap {
+ private header "__algorithm/ranges_is_heap.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_is_heap_until {
+ private header "__algorithm/ranges_is_heap_until.h"
+ export functional.__functional.ranges_operations
+ }
module ranges_is_partitioned { private header "__algorithm/ranges_is_partitioned.h" }
- module ranges_is_sorted { private header "__algorithm/ranges_is_sorted.h" }
- module ranges_is_sorted_until { private header "__algorithm/ranges_is_sorted_until.h" }
+ module ranges_is_permutation { private header "__algorithm/ranges_is_permutation.h" }
+ module ranges_is_sorted {
+ private header "__algorithm/ranges_is_sorted.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_is_sorted_until {
+ private header "__algorithm/ranges_is_sorted_until.h"
+ export functional.__functional.ranges_operations
+ }
module ranges_iterator_concept { private header "__algorithm/ranges_iterator_concept.h" }
- module ranges_lexicographical_compare { private header "__algorithm/ranges_lexicographical_compare.h" }
- module ranges_lower_bound { private header "__algorithm/ranges_lower_bound.h" }
- module ranges_make_heap { private header "__algorithm/ranges_make_heap.h" }
- module ranges_max { private header "__algorithm/ranges_max.h" }
- module ranges_max_element { private header "__algorithm/ranges_max_element.h" }
- module ranges_merge { private header "__algorithm/ranges_merge.h" }
- module ranges_min { private header "__algorithm/ranges_min.h" }
- module ranges_min_element { private header "__algorithm/ranges_min_element.h" }
- module ranges_minmax { private header "__algorithm/ranges_minmax.h" }
- module ranges_minmax_element { private header "__algorithm/ranges_minmax_element.h" }
- module ranges_mismatch { private header "__algorithm/ranges_mismatch.h" }
- module ranges_move { private header "__algorithm/ranges_move.h" }
- module ranges_move_backward { private header "__algorithm/ranges_move_backward.h" }
+ module ranges_lexicographical_compare {
+ private header "__algorithm/ranges_lexicographical_compare.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_lower_bound {
+ private header "__algorithm/ranges_lower_bound.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_make_heap {
+ private header "__algorithm/ranges_make_heap.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_max {
+ private header "__algorithm/ranges_max.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_max_element {
+ private header "__algorithm/ranges_max_element.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_merge {
+ private header "__algorithm/ranges_merge.h"
+ export algorithm.__algorithm.in_in_out_result
+ }
+ module ranges_min {
+ private header "__algorithm/ranges_min.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_min_element {
+ private header "__algorithm/ranges_min_element.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_minmax {
+ private header "__algorithm/ranges_minmax.h"
+ export functional.__functional.ranges_operations
+ export algorithm.__algorithm.min_max_result
+ }
+ module ranges_minmax_element {
+ private header "__algorithm/ranges_minmax_element.h"
+ export functional.__functional.ranges_operations
+ export algorithm.__algorithm.min_max_result
+ }
+ module ranges_mismatch {
+ private header "__algorithm/ranges_mismatch.h"
+ export algorithm.__algorithm.in_in_result
+ }
+ module ranges_move {
+ private header "__algorithm/ranges_move.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_move_backward {
+ private header "__algorithm/ranges_move_backward.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_next_permutation {
+ private header "__algorithm/ranges_next_permutation.h"
+ export algorithm.__algorithm.in_found_result
+ export functional.__functional.ranges_operations
+ }
module ranges_none_of { private header "__algorithm/ranges_none_of.h" }
- module ranges_nth_element { private header "__algorithm/ranges_nth_element.h" }
- module ranges_partial_sort { private header "__algorithm/ranges_partial_sort.h" }
- module ranges_partial_sort_copy { private header "__algorithm/ranges_partial_sort_copy.h" }
+ module ranges_nth_element {
+ private header "__algorithm/ranges_nth_element.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_partial_sort {
+ private header "__algorithm/ranges_partial_sort.h"
+ export algorithm.__algorithm.in_out_result
+ export functional.__functional.ranges_operations
+ }
+ module ranges_partial_sort_copy {
+ private header "__algorithm/ranges_partial_sort_copy.h"
+ export algorithm.__algorithm.in_out_out_result
+ export functional.__functional.ranges_operations
+ }
module ranges_partition { private header "__algorithm/ranges_partition.h" }
module ranges_partition_copy { private header "__algorithm/ranges_partition_copy.h" }
module ranges_partition_point { private header "__algorithm/ranges_partition_point.h" }
- module ranges_pop_heap { private header "__algorithm/ranges_pop_heap.h" }
- module ranges_push_heap { private header "__algorithm/ranges_push_heap.h" }
+ module ranges_pop_heap {
+ private header "__algorithm/ranges_pop_heap.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_prev_permutation {
+ private header "__algorithm/ranges_prev_permutation.h"
+ export algorithm.__algorithm.in_found_result
+ export functional.__functional.ranges_operations
+ }
+ module ranges_push_heap {
+ private header "__algorithm/ranges_push_heap.h"
+ export functional.__functional.ranges_operations
+ }
module ranges_remove { private header "__algorithm/ranges_remove.h" }
- module ranges_remove_copy { private header "__algorithm/ranges_remove_copy.h" }
- module ranges_remove_copy_if { private header "__algorithm/ranges_remove_copy_if.h" }
+ module ranges_remove_copy {
+ private header "__algorithm/ranges_remove_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_remove_copy_if {
+ private header "__algorithm/ranges_remove_copy_if.h"
+ export algorithm.__algorithm.in_out_result
+ }
module ranges_remove_if { private header "__algorithm/ranges_remove_if.h" }
module ranges_replace { private header "__algorithm/ranges_replace.h" }
- module ranges_replace_copy { private header "__algorithm/ranges_replace_copy.h" }
- module ranges_replace_copy_if { private header "__algorithm/ranges_replace_copy_if.h" }
+ module ranges_replace_copy {
+ private header "__algorithm/ranges_replace_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_replace_copy_if {
+ private header "__algorithm/ranges_replace_copy_if.h"
+ export algorithm.__algorithm.in_out_result
+ }
module ranges_replace_if { private header "__algorithm/ranges_replace_if.h" }
module ranges_reverse { private header "__algorithm/ranges_reverse.h" }
- module ranges_reverse_copy { private header "__algorithm/ranges_reverse_copy.h" }
- module ranges_rotate_copy { private header "__algorithm/ranges_rotate_copy.h" }
+ module ranges_reverse_copy {
+ private header "__algorithm/ranges_reverse_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_rotate { private header "__algorithm/ranges_rotate.h" }
+ module ranges_rotate_copy {
+ private header "__algorithm/ranges_rotate_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_sample { private header "__algorithm/ranges_sample.h" }
module ranges_search { private header "__algorithm/ranges_search.h" }
module ranges_search_n { private header "__algorithm/ranges_search_n.h" }
- module ranges_set_difference { private header "__algorithm/ranges_set_difference.h" }
- module ranges_set_intersection { private header "__algorithm/ranges_set_intersection.h" }
- module ranges_set_symmetric_difference { private header "__algorithm/ranges_set_symmetric_difference.h" }
- module ranges_set_union { private header "__algorithm/ranges_set_union.h" }
+ module ranges_set_difference {
+ private header "__algorithm/ranges_set_difference.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_set_intersection {
+ private header "__algorithm/ranges_set_intersection.h"
+ export algorithm.__algorithm.in_in_out_result
+ }
+ module ranges_set_symmetric_difference {
+ private header "__algorithm/ranges_set_symmetric_difference.h"
+ export algorithm.__algorithm.in_in_out_result
+ export functional.__functional.ranges_operations
+ }
+ module ranges_set_union {
+ private header "__algorithm/ranges_set_union.h"
+ export algorithm.__algorithm.in_in_out_result
+ export functional.__functional.ranges_operations
+ }
module ranges_shuffle { private header "__algorithm/ranges_shuffle.h" }
- module ranges_sort { private header "__algorithm/ranges_sort.h" }
- module ranges_sort_heap { private header "__algorithm/ranges_sort_heap.h" }
+ module ranges_sort {
+ private header "__algorithm/ranges_sort.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_sort_heap {
+ private header "__algorithm/ranges_sort_heap.h"
+ export functional.__functional.ranges_operations
+ }
module ranges_stable_partition { private header "__algorithm/ranges_stable_partition.h" }
- module ranges_stable_sort { private header "__algorithm/ranges_stable_sort.h" }
- module ranges_swap_ranges { private header "__algorithm/ranges_swap_ranges.h" }
- module ranges_transform { private header "__algorithm/ranges_transform.h" }
+ module ranges_stable_sort {
+ private header "__algorithm/ranges_stable_sort.h"
+ export functional.__functional.ranges_operations
+ }
+ module ranges_swap_ranges {
+ private header "__algorithm/ranges_swap_ranges.h"
+ export algorithm.__algorithm.in_in_result
+ }
+ module ranges_transform {
+ private header "__algorithm/ranges_transform.h"
+ export algorithm.__algorithm.in_in_out_result
+ export algorithm.__algorithm.in_out_result
+ }
+ module uniform_random_bit_generator_adaptor {
+ private header "__algorithm/uniform_random_bit_generator_adaptor.h"
+ }
module ranges_unique { private header "__algorithm/ranges_unique.h" }
- module ranges_unique_copy { private header "__algorithm/ranges_unique_copy.h" }
- module ranges_upper_bound { private header "__algorithm/ranges_upper_bound.h" }
+ module ranges_unique_copy {
+ private header "__algorithm/ranges_unique_copy.h"
+ export algorithm.__algorithm.in_out_result
+ }
+ module ranges_upper_bound {
+ private header "__algorithm/ranges_upper_bound.h"
+ export functional.__functional.ranges_operations
+ }
module remove { private header "__algorithm/remove.h" }
module remove_copy { private header "__algorithm/remove_copy.h" }
module remove_copy_if { private header "__algorithm/remove_copy_if.h" }
@@ -419,6 +600,7 @@ module std [system] {
module unique { private header "__algorithm/unique.h" }
module unique_copy { private header "__algorithm/unique_copy.h" }
module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
+ module unwrap_range { private header "__algorithm/unwrap_range.h" }
module upper_bound { private header "__algorithm/upper_bound.h" }
}
}
@@ -430,6 +612,8 @@ module std [system] {
header "array"
export initializer_list
export *
+
+ module array_fwd { private header "__fwd/array.h" }
}
module atomic {
header "atomic"
@@ -445,8 +629,19 @@ module std [system] {
export *
module __bit {
- module bit_cast { private header "__bit/bit_cast.h" }
- module byteswap { private header "__bit/byteswap.h" }
+ module bit_cast { private header "__bit/bit_cast.h" }
+ module bit_ceil { private header "__bit/bit_ceil.h" }
+ module bit_floor { private header "__bit/bit_floor.h" }
+ module bit_log2 { private header "__bit/bit_log2.h" }
+ module bit_width { private header "__bit/bit_width.h" }
+ module blsr { private header "__bit/blsr.h" }
+ module byteswap { private header "__bit/byteswap.h" }
+ module countl { private header "__bit/countl.h" }
+ module countr { private header "__bit/countr.h" }
+ module endian { private header "__bit/endian.h" }
+ module has_single_bit { private header "__bit/has_single_bit.h" }
+ module popcount { private header "__bit/popcount.h" }
+ module rotate { private header "__bit/rotate.h" }
}
}
module bitset {
@@ -474,29 +669,44 @@ module std [system] {
export *
module __chrono {
- module calendar { private header "__chrono/calendar.h" }
- module convert_to_timespec { private header "__chrono/convert_to_timespec.h" }
- module day { private header "__chrono/day.h" }
- module duration { private header "__chrono/duration.h" }
- module file_clock { private header "__chrono/file_clock.h" }
- module hh_mm_ss { private header "__chrono/hh_mm_ss.h" }
- module high_resolution_clock {
+ module calendar { private header "__chrono/calendar.h" }
+ module convert_to_timespec { private header "__chrono/convert_to_timespec.h" }
+ module convert_to_tm { private header "__chrono/convert_to_tm.h" }
+ module day { private header "__chrono/day.h" }
+ module duration { private header "__chrono/duration.h" }
+ module file_clock { private header "__chrono/file_clock.h" }
+ module formatter {
+ @requires_LIBCXX_ENABLE_LOCALIZATION@
+ private header "__chrono/formatter.h"
+ }
+ module hh_mm_ss { private header "__chrono/hh_mm_ss.h" }
+ module high_resolution_clock {
private header "__chrono/high_resolution_clock.h"
export steady_clock
export system_clock
+ export time_point
+ }
+ module literals { private header "__chrono/literals.h" }
+ module month { private header "__chrono/month.h" }
+ module month_weekday { private header "__chrono/month_weekday.h" }
+ module monthday { private header "__chrono/monthday.h" }
+ module ostream {
+ @requires_LIBCXX_ENABLE_LOCALIZATION@
+ private header "__chrono/ostream.h"
+ }
+ module parser_std_format_spec {
+ @requires_LIBCXX_ENABLE_LOCALIZATION@
+ private header "__chrono/parser_std_format_spec.h"
}
- module literals { private header "__chrono/literals.h" }
- module month { private header "__chrono/month.h" }
- module month_weekday { private header "__chrono/month_weekday.h" }
- module monthday { private header "__chrono/monthday.h" }
- module steady_clock { private header "__chrono/steady_clock.h" }
- module system_clock { private header "__chrono/system_clock.h" }
- module time_point { private header "__chrono/time_point.h" }
- module weekday { private header "__chrono/weekday.h" }
- module year { private header "__chrono/year.h" }
- module year_month { private header "__chrono/year_month.h" }
- module year_month_day { private header "__chrono/year_month_day.h" }
- module year_month_weekday { private header "__chrono/year_month_weekday.h" }
+ module statically_widen { private header "__chrono/statically_widen.h" }
+ module steady_clock { private header "__chrono/steady_clock.h" }
+ module system_clock { private header "__chrono/system_clock.h" }
+ module time_point { private header "__chrono/time_point.h" }
+ module weekday { private header "__chrono/weekday.h" }
+ module year { private header "__chrono/year.h" }
+ module year_month { private header "__chrono/year_month.h" }
+ module year_month_day { private header "__chrono/year_month_day.h" }
+ module year_month_weekday { private header "__chrono/year_month_weekday.h" }
}
}
module codecvt {
@@ -587,6 +797,17 @@ module std [system] {
header "execution"
export *
}
+ module expected {
+ header "expected"
+ export *
+
+ module __expected {
+ module bad_expected_access { private header "__expected/bad_expected_access.h" }
+ module expected { private header "__expected/expected.h" }
+ module unexpect { private header "__expected/unexpect.h" }
+ module unexpected { private header "__expected/unexpected.h" }
+ }
+ }
module filesystem {
@requires_LIBCXX_ENABLE_FILESYSTEM@
header "filesystem"
@@ -618,7 +839,9 @@ module std [system] {
module __format {
module buffer { private header "__format/buffer.h" }
module concepts { private header "__format/concepts.h" }
+ module container_adaptor { private header "__format/container_adaptor.h" }
module enable_insertable { private header "__format/enable_insertable.h" }
+ module escaped_output_table { private header "__format/escaped_output_table.h" }
module extended_grapheme_cluster_table { private header "__format/extended_grapheme_cluster_table.h" }
module format_arg { private header "__format/format_arg.h" }
module format_arg_store { private header "__format/format_arg_store.h" }
@@ -629,10 +852,14 @@ module std [system] {
export locale
}
module format_error { private header "__format/format_error.h" }
+ module format_functions { private header "__format/format_functions.h" }
module format_fwd { private header "__format/format_fwd.h" }
module format_parse_context { private header "__format/format_parse_context.h" }
module format_string { private header "__format/format_string.h" }
- module format_to_n_result { private header "__format/format_to_n_result.h" }
+ module format_to_n_result {
+ private header "__format/format_to_n_result.h"
+ export iterator.__iterator.incrementable_traits
+ }
module formatter { private header "__format/formatter.h" }
module formatter_bool { private header "__format/formatter_bool.h" }
module formatter_char { private header "__format/formatter_char.h" }
@@ -642,7 +869,10 @@ module std [system] {
module formatter_output { private header "__format/formatter_output.h" }
module formatter_pointer { private header "__format/formatter_pointer.h" }
module formatter_string { private header "__format/formatter_string.h" }
+ module formatter_tuple { private header "__format/formatter_tuple.h" }
module parser_std_format_spec { private header "__format/parser_std_format_spec.h" }
+ module range_default_formatter { private header "__format/range_default_formatter.h" }
+ module range_formatter { private header "__format/range_formatter.h" }
module unicode { private header "__format/unicode.h" }
}
}
@@ -653,6 +883,7 @@ module std [system] {
}
module fstream {
@requires_LIBCXX_ENABLE_LOCALIZATION@
+ @requires_LIBCXX_ENABLE_FSTREAM@
header "fstream"
export *
}
@@ -673,8 +904,12 @@ module std [system] {
module default_searcher { private header "__functional/default_searcher.h" }
module function { private header "__functional/function.h" }
module hash { private header "__functional/hash.h" }
+ module hash_fwd { private header "__fwd/hash.h" }
module identity { private header "__functional/identity.h" }
- module invoke { private header "__functional/invoke.h" }
+ module invoke {
+ private header "__functional/invoke.h"
+ export type_traits
+ }
module is_transparent { private header "__functional/is_transparent.h" }
module mem_fn { private header "__functional/mem_fn.h" }
module mem_fun_ref { private header "__functional/mem_fun_ref.h" }
@@ -761,7 +996,11 @@ module std [system] {
module iter_swap { private header "__iterator/iter_swap.h" }
module iterator { private header "__iterator/iterator.h" }
module iterator_traits { private header "__iterator/iterator_traits.h" }
- module mergeable { private header "__iterator/mergeable.h" }
+ module iterator_with_data { private header "__iterator/iterator_with_data.h" }
+ module mergeable {
+ private header "__iterator/mergeable.h"
+ export functional.__functional.ranges_operations
+ }
module move_iterator { private header "__iterator/move_iterator.h" }
module move_sentinel { private header "__iterator/move_sentinel.h" }
module next { private header "__iterator/next.h" }
@@ -776,8 +1015,12 @@ module std [system] {
module readable_traits { private header "__iterator/readable_traits.h" }
module reverse_access { private header "__iterator/reverse_access.h" }
module reverse_iterator { private header "__iterator/reverse_iterator.h" }
+ module segmented_iterator { private header "__iterator/segmented_iterator.h" }
module size { private header "__iterator/size.h" }
- module sortable { private header "__iterator/sortable.h" }
+ module sortable {
+ private header "__iterator/sortable.h"
+ export functional.__functional.ranges_operations
+ }
module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" }
module wrap_iter { private header "__iterator/wrap_iter.h" }
}
@@ -817,29 +1060,52 @@ module std [system] {
module __memory {
module addressof { private header "__memory/addressof.h" }
+ module align { private header "__memory/align.h" }
module allocate_at_least { private header "__memory/allocate_at_least.h" }
module allocation_guard { private header "__memory/allocation_guard.h" }
module allocator { private header "__memory/allocator.h" }
module allocator_arg_t { private header "__memory/allocator_arg_t.h" }
+ module allocator_destructor { private header "__memory/allocator_destructor.h" }
module allocator_traits { private header "__memory/allocator_traits.h" }
module assume_aligned { private header "__memory/assume_aligned.h" }
module auto_ptr { private header "__memory/auto_ptr.h" }
+ module builtin_new_allocator { private header "__memory/builtin_new_allocator.h" }
module compressed_pair { private header "__memory/compressed_pair.h" }
module concepts { private header "__memory/concepts.h" }
module construct_at { private header "__memory/construct_at.h" }
+ module destruct_n { private header "__memory/destruct_n.h" }
module pointer_traits { private header "__memory/pointer_traits.h" }
module ranges_construct_at { private header "__memory/ranges_construct_at.h" }
- module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" }
+ module ranges_uninitialized_algorithms {
+ private header "__memory/ranges_uninitialized_algorithms.h"
+ export algorithm.__algorithm.in_out_result
+ }
module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" }
module shared_ptr { private header "__memory/shared_ptr.h" }
module swap_allocator { private header "__memory/swap_allocator.h" }
+ module temp_value { private header "__memory/temp_value.h" }
module temporary_buffer { private header "__memory/temporary_buffer.h" }
module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
module unique_ptr { private header "__memory/unique_ptr.h" }
module uses_allocator { private header "__memory/uses_allocator.h" }
+ module uses_allocator_construction { private header "__memory/uses_allocator_construction.h" }
module voidify { private header "__memory/voidify.h" }
}
}
+ module memory_resource {
+ header "memory_resource"
+ export *
+
+ module __memory_resource {
+ module memory_resource { private header "__memory_resource/memory_resource.h" }
+ module memory_resource_fwd { private header "__fwd/memory_resource.h" }
+ module monotonic_buffer_resource { private header "__memory_resource/monotonic_buffer_resource.h" }
+ module polymorphic_allocator { private header "__memory_resource/polymorphic_allocator.h" }
+ module pool_options { private header "__memory_resource/pool_options.h" }
+ module synchronized_pool_resource { private header "__memory_resource/synchronized_pool_resource.h" }
+ module unsynchronized_pool_resource { private header "__memory_resource/unsynchronized_pool_resource.h" }
+ }
+ }
module mutex {
@requires_LIBCXX_ENABLE_THREADS@
header "mutex"
@@ -901,7 +1167,10 @@ module std [system] {
module clamp_to_integral { private header "__random/clamp_to_integral.h" }
module default_random_engine { private header "__random/default_random_engine.h" }
module discard_block_engine { private header "__random/discard_block_engine.h" }
- module discrete_distribution { private header "__random/discrete_distribution.h" }
+ module discrete_distribution {
+ private header "__random/discrete_distribution.h"
+ export vector
+ }
module exponential_distribution { private header "__random/exponential_distribution.h" }
module extreme_value_distribution { private header "__random/extreme_value_distribution.h" }
module fisher_f_distribution { private header "__random/fisher_f_distribution.h" }
@@ -918,8 +1187,14 @@ module std [system] {
module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" }
module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" }
module normal_distribution { private header "__random/normal_distribution.h" }
- module piecewise_constant_distribution { private header "__random/piecewise_constant_distribution.h" }
- module piecewise_linear_distribution { private header "__random/piecewise_linear_distribution.h" }
+ module piecewise_constant_distribution {
+ private header "__random/piecewise_constant_distribution.h"
+ export vector
+ }
+ module piecewise_linear_distribution {
+ private header "__random/piecewise_linear_distribution.h"
+ export vector
+ }
module poisson_distribution { private header "__random/poisson_distribution.h" }
module random_device { private header "__random/random_device.h" }
module ranlux { private header "__random/ranlux.h" }
@@ -947,6 +1222,7 @@ module std [system] {
export functional.__functional.compose
export functional.__functional.perfect_forward
}
+ module as_rvalue_view { private header "__ranges/as_rvalue_view.h" }
module common_view { private header "__ranges/common_view.h" }
module concepts { private header "__ranges/concepts.h" }
module copyable_box { private header "__ranges/copyable_box.h" }
@@ -957,12 +1233,18 @@ module std [system] {
module dangling { private header "__ranges/dangling.h" }
module data { private header "__ranges/data.h" }
module drop_view { private header "__ranges/drop_view.h" }
+ module drop_while_view { private header "__ranges/drop_while_view.h" }
+ module elements_view { private header "__ranges/elements_view.h" }
module empty { private header "__ranges/empty.h" }
module empty_view { private header "__ranges/empty_view.h" }
module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" }
module enable_view { private header "__ranges/enable_view.h" }
module filter_view { private header "__ranges/filter_view.h" }
module iota_view { private header "__ranges/iota_view.h" }
+ module istream_view {
+ @requires_LIBCXX_ENABLE_LOCALIZATION@
+ private header "__ranges/istream_view.h"
+ }
module join_view { private header "__ranges/join_view.h" }
module lazy_split_view { private header "__ranges/lazy_split_view.h" }
module non_propagating_cache { private header "__ranges/non_propagating_cache.h" }
@@ -974,8 +1256,14 @@ module std [system] {
module reverse_view { private header "__ranges/reverse_view.h" }
module single_view { private header "__ranges/single_view.h" }
module size { private header "__ranges/size.h" }
- module subrange { private header "__ranges/subrange.h" }
+ module split_view { private header "__ranges/split_view.h" }
+ module subrange {
+ private header "__ranges/subrange.h"
+
+ module subrange_fwd { private header "__fwd/subrange.h" }
+ }
module take_view { private header "__ranges/take_view.h" }
+ module take_while_view { private header "__ranges/take_while_view.h" }
module transform_view {
private header "__ranges/transform_view.h"
export functional.__functional.bind_back
@@ -1015,6 +1303,10 @@ module std [system] {
header "shared_mutex"
export version
}
+ module source_location {
+ header "source_location"
+ export *
+ }
module span {
header "span"
export ranges.__ranges.enable_borrowed_range
@@ -1048,6 +1340,7 @@ module std [system] {
module __string {
module char_traits { private header "__string/char_traits.h" }
module extern_template_lists { private header "__string/extern_template_lists.h" }
+ module string_fwd { private header "__fwd/string.h" }
}
export *
}
@@ -1079,128 +1372,170 @@ module std [system] {
module tuple {
header "tuple"
export *
+
+ module apply_cv { private header "__tuple_dir/apply_cv.h" }
+ module get_fwd { private header "__fwd/get.h" }
+ module make_tuple_types { private header "__tuple_dir/make_tuple_types.h" }
+ module pair_like { private header "__tuple_dir/pair_like.h" }
+ module sfinae_helpers { private header "__tuple_dir/sfinae_helpers.h" }
+ module tuple_element { private header "__tuple_dir/tuple_element.h" }
+ module tuple_fwd { private header "__fwd/tuple.h" }
+ module tuple_indices { private header "__tuple_dir/tuple_indices.h" }
+ module tuple_like { private header "__tuple_dir/tuple_like.h" }
+ module tuple_like_ext { private header "__tuple_dir/tuple_like_ext.h" }
+ module tuple_size { private header "__tuple_dir/tuple_size.h" }
+ module tuple_types { private header "__tuple_dir/tuple_types.h" }
}
module type_traits {
header "type_traits"
export functional.__functional.unwrap_ref
export *
- module add_const { private header "__type_traits/add_const.h" }
- module add_cv { private header "__type_traits/add_cv.h" }
- module add_lvalue_reference { private header "__type_traits/add_lvalue_reference.h" }
- module add_pointer { private header "__type_traits/add_pointer.h" }
- module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" }
- module add_volatile { private header "__type_traits/add_volatile.h" }
- module aligned_storage { private header "__type_traits/aligned_storage.h" }
- module aligned_union { private header "__type_traits/aligned_union.h" }
- module alignment_of { private header "__type_traits/alignment_of.h" }
- module apply_cv { private header "__type_traits/apply_cv.h" }
- module common_reference { private header "__type_traits/common_reference.h" }
- module common_type { private header "__type_traits/common_type.h" }
- module conditional { private header "__type_traits/conditional.h" }
- module conjunction { private header "__type_traits/conjunction.h" }
- module copy_cv { private header "__type_traits/copy_cv.h" }
- module copy_cvref { private header "__type_traits/copy_cvref.h" }
- module decay { private header "__type_traits/decay.h" }
- module disjunction { private header "__type_traits/disjunction.h" }
- module enable_if { private header "__type_traits/enable_if.h" }
- module extent { private header "__type_traits/extent.h" }
- module has_unique_object_representation { private header "__type_traits/has_unique_object_representation.h" }
- module has_virtual_destructor { private header "__type_traits/has_virtual_destructor.h" }
- module integral_constant { private header "__type_traits/integral_constant.h" }
- module is_abstract { private header "__type_traits/is_abstract.h" }
- module is_aggregate { private header "__type_traits/is_aggregate.h" }
- module is_arithmetic { private header "__type_traits/is_arithmetic.h" }
- module is_array { private header "__type_traits/is_array.h" }
- module is_assignable { private header "__type_traits/is_assignable.h" }
- module is_base_of { private header "__type_traits/is_base_of.h" }
- module is_bounded_array { private header "__type_traits/is_bounded_array.h" }
- module is_callable { private header "__type_traits/is_callable.h" }
- module is_class { private header "__type_traits/is_class.h" }
- module is_compound { private header "__type_traits/is_compound.h" }
- module is_const { private header "__type_traits/is_const.h" }
- module is_constant_evaluated { private header "__type_traits/is_constant_evaluated.h" }
- module is_constructible { private header "__type_traits/is_constructible.h" }
- module is_convertible { private header "__type_traits/is_convertible.h" }
- module is_copy_assignable { private header "__type_traits/is_copy_assignable.h" }
- module is_copy_constructible { private header "__type_traits/is_copy_constructible.h" }
- module is_core_convertible { private header "__type_traits/is_core_convertible.h" }
- module is_default_constructible { private header "__type_traits/is_default_constructible.h" }
- module is_destructible { private header "__type_traits/is_destructible.h" }
- module is_empty { private header "__type_traits/is_empty.h" }
- module is_enum { private header "__type_traits/is_enum.h" }
- module is_final { private header "__type_traits/is_final.h" }
- module is_floating_point { private header "__type_traits/is_floating_point.h" }
- module is_function { private header "__type_traits/is_function.h" }
- module is_fundamental { private header "__type_traits/is_fundamental.h" }
- module is_integral { private header "__type_traits/is_integral.h" }
- module is_literal_type { private header "__type_traits/is_literal_type.h" }
- module is_member_function_pointer { private header "__type_traits/is_member_function_pointer.h" }
- module is_member_object_pointer { private header "__type_traits/is_member_object_pointer.h" }
- module is_member_pointer { private header "__type_traits/is_member_pointer.h" }
- module is_move_assignable { private header "__type_traits/is_move_assignable.h" }
- module is_move_constructible { private header "__type_traits/is_move_constructible.h" }
- module is_nothrow_assignable { private header "__type_traits/is_nothrow_assignable.h" }
- module is_nothrow_constructible { private header "__type_traits/is_nothrow_constructible.h" }
- module is_nothrow_convertible { private header "__type_traits/is_nothrow_convertible.h" }
- module is_nothrow_copy_assignable { private header "__type_traits/is_nothrow_copy_assignable.h" }
- module is_nothrow_copy_constructible { private header "__type_traits/is_nothrow_copy_constructible.h" }
- module is_nothrow_default_constructible { private header "__type_traits/is_nothrow_default_constructible.h" }
- module is_nothrow_destructible { private header "__type_traits/is_nothrow_destructible.h" }
- module is_nothrow_move_assignable { private header "__type_traits/is_nothrow_move_assignable.h" }
- module is_nothrow_move_constructible { private header "__type_traits/is_nothrow_move_constructible.h" }
- module is_null_pointer { private header "__type_traits/is_null_pointer.h" }
- module is_object { private header "__type_traits/is_object.h" }
- module is_pod { private header "__type_traits/is_pod.h" }
- module is_pointer { private header "__type_traits/is_pointer.h" }
- module is_polymorphic { private header "__type_traits/is_polymorphic.h" }
- module is_primary_template { private header "__type_traits/is_primary_template.h" }
- module is_reference { private header "__type_traits/is_reference.h" }
- module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" }
- module is_referenceable { private header "__type_traits/is_referenceable.h" }
- module is_same { private header "__type_traits/is_same.h" }
- module is_scalar { private header "__type_traits/is_scalar.h" }
- module is_scoped_enum { private header "__type_traits/is_scoped_enum.h" }
- module is_signed { private header "__type_traits/is_signed.h" }
- module is_signed_integer { private header "__type_traits/is_signed_integer.h" }
- module is_standard_layout { private header "__type_traits/is_standard_layout.h" }
- module is_trivial { private header "__type_traits/is_trivial.h" }
- module is_trivially_assignable { private header "__type_traits/is_trivially_assignable.h" }
- module is_trivially_constructible { private header "__type_traits/is_trivially_constructible.h" }
- module is_trivially_copy_assignable { private header "__type_traits/is_trivially_copy_assignable.h" }
- module is_trivially_copy_constructible { private header "__type_traits/is_trivially_copy_constructible.h" }
- module is_trivially_copyable { private header "__type_traits/is_trivially_copyable.h" }
- module is_trivially_default_constructible { private header "__type_traits/is_trivially_default_constructible.h" }
- module is_trivially_destructible { private header "__type_traits/is_trivially_destructible.h" }
- module is_trivially_move_assignable { private header "__type_traits/is_trivially_move_assignable.h" }
- module is_trivially_move_constructible { private header "__type_traits/is_trivially_move_constructible.h" }
- module is_unbounded_array { private header "__type_traits/is_unbounded_array.h" }
- module is_union { private header "__type_traits/is_union.h" }
- module is_unsigned { private header "__type_traits/is_unsigned.h" }
- module is_unsigned_integer { private header "__type_traits/is_unsigned_integer.h" }
- module is_valid_expansion { private header "__type_traits/is_valid_expansion.h" }
- module is_void { private header "__type_traits/is_void.h" }
- module is_volatile { private header "__type_traits/is_volatile.h" }
- module lazy { private header "__type_traits/lazy.h" }
- module make_32_64_or_128_bit { private header "__type_traits/make_32_64_or_128_bit.h" }
- module make_signed { private header "__type_traits/make_signed.h" }
- module make_unsigned { private header "__type_traits/make_unsigned.h" }
- module nat { private header "__type_traits/nat.h" }
- module negation { private header "__type_traits/negation.h" }
- module promote { private header "__type_traits/promote.h" }
- module rank { private header "__type_traits/rank.h" }
- module remove_all_extents { private header "__type_traits/remove_all_extents.h" }
- module remove_const { private header "__type_traits/remove_const.h" }
- module remove_cv { private header "__type_traits/remove_cv.h" }
- module remove_cvref { private header "__type_traits/remove_cvref.h" }
- module remove_extent { private header "__type_traits/remove_extent.h" }
- module remove_pointer { private header "__type_traits/remove_pointer.h" }
- module remove_reference { private header "__type_traits/remove_reference.h" }
- module remove_volatile { private header "__type_traits/remove_volatile.h" }
- module type_identity { private header "__type_traits/type_identity.h" }
- module type_list { private header "__type_traits/type_list.h" }
- module underlying_type { private header "__type_traits/underlying_type.h" }
- module void_t { private header "__type_traits/void_t.h" }
+ module add_const { private header "__type_traits/add_const.h" }
+ module add_cv { private header "__type_traits/add_cv.h" }
+ module add_lvalue_reference { private header "__type_traits/add_lvalue_reference.h" }
+ module add_pointer { private header "__type_traits/add_pointer.h" }
+ module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" }
+ module add_volatile { private header "__type_traits/add_volatile.h" }
+ module aligned_storage { private header "__type_traits/aligned_storage.h" }
+ module aligned_union { private header "__type_traits/aligned_union.h" }
+ module alignment_of { private header "__type_traits/alignment_of.h" }
+ module apply_cv { private header "__type_traits/apply_cv.h" }
+ module can_extract_key { private header "__type_traits/can_extract_key.h" }
+ module common_reference { private header "__type_traits/common_reference.h" }
+ module common_type { private header "__type_traits/common_type.h" }
+ module conditional { private header "__type_traits/conditional.h" }
+ module conjunction { private header "__type_traits/conjunction.h" }
+ module copy_cv { private header "__type_traits/copy_cv.h" }
+ module copy_cvref { private header "__type_traits/copy_cvref.h" }
+ module decay { private header "__type_traits/decay.h" }
+ module dependent_type { private header "__type_traits/dependent_type.h" }
+ module disjunction { private header "__type_traits/disjunction.h" }
+ module enable_if { private header "__type_traits/enable_if.h" }
+ module extent { private header "__type_traits/extent.h" }
+ module has_unique_object_representation { private header "__type_traits/has_unique_object_representation.h" }
+ module has_virtual_destructor { private header "__type_traits/has_virtual_destructor.h" }
+ module integral_constant { private header "__type_traits/integral_constant.h" }
+ module is_abstract { private header "__type_traits/is_abstract.h" }
+ module is_aggregate { private header "__type_traits/is_aggregate.h" }
+ module is_allocator { private header "__type_traits/is_allocator.h" }
+ module is_always_bitcastable { private header "__type_traits/is_always_bitcastable.h" }
+ module is_arithmetic {
+ private header "__type_traits/is_arithmetic.h"
+ export integral_constant
+ }
+ module is_array {
+ private header "__type_traits/is_array.h"
+ export integral_constant
+ }
+ module is_assignable { private header "__type_traits/is_assignable.h" }
+ module is_base_of { private header "__type_traits/is_base_of.h" }
+ module is_bounded_array { private header "__type_traits/is_bounded_array.h" }
+ module is_callable { private header "__type_traits/is_callable.h" }
+ module is_char_like_type { private header "__type_traits/is_char_like_type.h" }
+ module is_class { private header "__type_traits/is_class.h" }
+ module is_compound { private header "__type_traits/is_compound.h" }
+ module is_const { private header "__type_traits/is_const.h" }
+ module is_constant_evaluated { private header "__type_traits/is_constant_evaluated.h" }
+ module is_constructible { private header "__type_traits/is_constructible.h" }
+ module is_convertible { private header "__type_traits/is_convertible.h" }
+ module is_copy_assignable { private header "__type_traits/is_copy_assignable.h" }
+ module is_copy_constructible { private header "__type_traits/is_copy_constructible.h" }
+ module is_core_convertible {
+ private header "__type_traits/is_core_convertible.h"
+ export integral_constant
+ }
+ module is_default_constructible { private header "__type_traits/is_default_constructible.h" }
+ module is_destructible { private header "__type_traits/is_destructible.h" }
+ module is_empty { private header "__type_traits/is_empty.h" }
+ module is_enum { private header "__type_traits/is_enum.h" }
+ module is_final { private header "__type_traits/is_final.h" }
+ module is_floating_point { private header "__type_traits/is_floating_point.h" }
+ module is_function { private header "__type_traits/is_function.h" }
+ module is_fundamental { private header "__type_traits/is_fundamental.h" }
+ module is_implicitly_default_constructible { private header "__type_traits/is_implicitly_default_constructible.h" }
+ module is_integral { private header "__type_traits/is_integral.h" }
+ module is_literal_type { private header "__type_traits/is_literal_type.h" }
+ module is_member_function_pointer { private header "__type_traits/is_member_function_pointer.h" }
+ module is_member_object_pointer { private header "__type_traits/is_member_object_pointer.h" }
+ module is_member_pointer { private header "__type_traits/is_member_pointer.h" }
+ module is_move_assignable { private header "__type_traits/is_move_assignable.h" }
+ module is_move_constructible { private header "__type_traits/is_move_constructible.h" }
+ module is_nothrow_assignable { private header "__type_traits/is_nothrow_assignable.h" }
+ module is_nothrow_constructible { private header "__type_traits/is_nothrow_constructible.h" }
+ module is_nothrow_convertible { private header "__type_traits/is_nothrow_convertible.h" }
+ module is_nothrow_copy_assignable { private header "__type_traits/is_nothrow_copy_assignable.h" }
+ module is_nothrow_copy_constructible { private header "__type_traits/is_nothrow_copy_constructible.h" }
+ module is_nothrow_default_constructible { private header "__type_traits/is_nothrow_default_constructible.h" }
+ module is_nothrow_destructible { private header "__type_traits/is_nothrow_destructible.h" }
+ module is_nothrow_move_assignable { private header "__type_traits/is_nothrow_move_assignable.h" }
+ module is_nothrow_move_constructible { private header "__type_traits/is_nothrow_move_constructible.h" }
+ module is_null_pointer { private header "__type_traits/is_null_pointer.h" }
+ module is_object { private header "__type_traits/is_object.h" }
+ module is_pod { private header "__type_traits/is_pod.h" }
+ module is_pointer { private header "__type_traits/is_pointer.h" }
+ module is_polymorphic { private header "__type_traits/is_polymorphic.h" }
+ module is_primary_template { private header "__type_traits/is_primary_template.h" }
+ module is_reference { private header "__type_traits/is_reference.h" }
+ module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" }
+ module is_referenceable { private header "__type_traits/is_referenceable.h" }
+ module is_same {
+ private header "__type_traits/is_same.h"
+ export type_traits.integral_constant
+ }
+ module is_scalar { private header "__type_traits/is_scalar.h" }
+ module is_scoped_enum { private header "__type_traits/is_scoped_enum.h" }
+ module is_signed { private header "__type_traits/is_signed.h" }
+ module is_signed_integer { private header "__type_traits/is_signed_integer.h" }
+ module is_specialization { private header "__type_traits/is_specialization.h" }
+ module is_standard_layout { private header "__type_traits/is_standard_layout.h" }
+ module is_swappable { private header "__type_traits/is_swappable.h" }
+ module is_trivial { private header "__type_traits/is_trivial.h" }
+ module is_trivially_assignable { private header "__type_traits/is_trivially_assignable.h" }
+ module is_trivially_constructible { private header "__type_traits/is_trivially_constructible.h" }
+ module is_trivially_copy_assignable { private header "__type_traits/is_trivially_copy_assignable.h" }
+ module is_trivially_copy_constructible { private header "__type_traits/is_trivially_copy_constructible.h" }
+ module is_trivially_copyable { private header "__type_traits/is_trivially_copyable.h" }
+ module is_trivially_default_constructible { private header "__type_traits/is_trivially_default_constructible.h" }
+ module is_trivially_destructible { private header "__type_traits/is_trivially_destructible.h" }
+ module is_trivially_move_assignable { private header "__type_traits/is_trivially_move_assignable.h" }
+ module is_trivially_move_constructible { private header "__type_traits/is_trivially_move_constructible.h" }
+ module is_unbounded_array { private header "__type_traits/is_unbounded_array.h" }
+ module is_union { private header "__type_traits/is_union.h" }
+ module is_unsigned { private header "__type_traits/is_unsigned.h" }
+ module is_unsigned_integer { private header "__type_traits/is_unsigned_integer.h" }
+ module is_valid_expansion { private header "__type_traits/is_valid_expansion.h" }
+ module is_void {
+ private header "__type_traits/is_void.h"
+ export integral_constant
+ }
+ module is_volatile { private header "__type_traits/is_volatile.h" }
+ module lazy { private header "__type_traits/lazy.h" }
+ module make_32_64_or_128_bit { private header "__type_traits/make_32_64_or_128_bit.h" }
+ module make_const_lvalue_ref { private header "__type_traits/make_const_lvalue_ref.h" }
+ module make_signed { private header "__type_traits/make_signed.h" }
+ module make_unsigned { private header "__type_traits/make_unsigned.h" }
+ module maybe_const { private header "__type_traits/maybe_const.h" }
+ module nat { private header "__type_traits/nat.h" }
+ module negation { private header "__type_traits/negation.h" }
+ module noexcept_move_assign_container { private header "__type_traits/noexcept_move_assign_container.h" }
+ module promote { private header "__type_traits/promote.h" }
+ module rank { private header "__type_traits/rank.h" }
+ module remove_all_extents { private header "__type_traits/remove_all_extents.h" }
+ module remove_const { private header "__type_traits/remove_const.h" }
+ module remove_const_ref { private header "__type_traits/remove_const_ref.h" }
+ module remove_cv { private header "__type_traits/remove_cv.h" }
+ module remove_cvref { private header "__type_traits/remove_cvref.h" }
+ module remove_extent { private header "__type_traits/remove_extent.h" }
+ module remove_pointer { private header "__type_traits/remove_pointer.h" }
+ module remove_reference { private header "__type_traits/remove_reference.h" }
+ module remove_volatile { private header "__type_traits/remove_volatile.h" }
+ module result_of { private header "__type_traits/result_of.h" }
+ module strip_signature { private header "__type_traits/strip_signature.h" }
+ module type_identity { private header "__type_traits/type_identity.h" }
+ module type_list { private header "__type_traits/type_list.h" }
+ module underlying_type { private header "__type_traits/underlying_type.h" }
+ module void_t { private header "__type_traits/void_t.h" }
}
module typeindex {
header "typeindex"
@@ -1229,19 +1564,22 @@ module std [system] {
module as_const { private header "__utility/as_const.h" }
module auto_cast { private header "__utility/auto_cast.h" }
module cmp { private header "__utility/cmp.h" }
+ module convert_to_integral { private header "__utility/convert_to_integral.h" }
module declval { private header "__utility/declval.h" }
+ module exception_guard { private header "__utility/exception_guard.h" }
module exchange { private header "__utility/exchange.h" }
module forward { private header "__utility/forward.h" }
+ module forward_like { private header "__utility/forward_like.h" }
module in_place { private header "__utility/in_place.h" }
module integer_sequence { private header "__utility/integer_sequence.h" }
module move { private header "__utility/move.h" }
module pair { private header "__utility/pair.h" }
+ module pair_fwd { private header "__fwd/pair.h" }
module piecewise_construct { private header "__utility/piecewise_construct.h" }
module priority_tag { private header "__utility/priority_tag.h" }
module rel_ops { private header "__utility/rel_ops.h" }
module swap { private header "__utility/swap.h" }
module to_underlying { private header "__utility/to_underlying.h" }
- module transaction { private header "__utility/transaction.h" }
module unreachable { private header "__utility/unreachable.h" }
}
}
@@ -1272,7 +1610,6 @@ module std [system] {
module __assert { header "__assert" export * }
module __availability { private header "__availability" export * }
module __bit_reference { private header "__bit_reference" export * }
- module __bits { private header "__bits" export * }
module __debug { header "__debug" export * }
module __errc { private header "__errc" export * }
module __hash_table { header "__hash_table" export * }
@@ -1290,8 +1627,8 @@ module std [system] {
}
module __threading_support { header "__threading_support" export * }
module __tree { header "__tree" export * }
- module __tuple { private header "__tuple" export * }
module __undef_macros { header "__undef_macros" export * }
+ module __verbose_abort { header "__verbose_abort" export * }
module experimental {
requires cplusplus11
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index 5dfaad2b3510..d93fba8f801c 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -188,20 +188,16 @@ template<class Callable, class ...Args>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__memory/shared_ptr.h>
#include <__mutex_base>
#include <__threading_support>
#include <__utility/forward.h>
#include <cstdint>
-#include <memory>
#ifndef _LIBCPP_CXX03_LANG
# include <tuple>
#endif
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -329,7 +325,7 @@ recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration
}
template <class _L0, class _L1>
-int
+_LIBCPP_HIDE_FROM_ABI int
try_lock(_L0& __l0, _L1& __l1)
{
unique_lock<_L0> __u0(__l0, try_to_lock);
@@ -349,14 +345,14 @@ try_lock(_L0& __l0, _L1& __l1)
#ifndef _LIBCPP_CXX03_LANG
template <class _L0, class _L1, class _L2, class... _L3>
-int
+_LIBCPP_HIDE_FROM_ABI 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...);
+ __r = std::try_lock(__l1, __l2, __l3...);
if (__r == -1)
__u0.release();
else
@@ -368,7 +364,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
#endif // _LIBCPP_CXX03_LANG
template <class _L0, class _L1>
-void
+_LIBCPP_HIDE_FROM_ABI void
lock(_L0& __l0, _L1& __l1)
{
while (true)
@@ -407,7 +403,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
case 0:
{
unique_lock<_L0> __u0(__l0);
- __i = try_lock(__l1, __l2, __l3...);
+ __i = std::try_lock(__l1, __l2, __l3...);
if (__i == -1)
{
__u0.release();
@@ -420,7 +416,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
case 1:
{
unique_lock<_L1> __u1(__l1);
- __i = try_lock(__l2, __l3..., __l0);
+ __i = std::try_lock(__l2, __l3..., __l0);
if (__i == -1)
{
__u1.release();
@@ -434,7 +430,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
__libcpp_thread_yield();
break;
default:
- __lock_first(__i - 2, __l2, __l3..., __l0, __l1);
+ std::__lock_first(__i - 2, __l2, __l3..., __l0, __l1);
return;
}
}
@@ -445,7 +441,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
{
- __lock_first(0, __l0, __l1, __l2, __l3...);
+ std::__lock_first(0, __l0, __l1, __l2, __l3...);
}
template <class _L0>
@@ -546,6 +542,7 @@ private:
_MutexTuple __t_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
#endif // _LIBCPP_STD_VER > 14
#endif // !_LIBCPP_HAS_NO_THREADS
@@ -670,7 +667,7 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
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>);
+ std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
}
}
@@ -684,7 +681,7 @@ call_once(once_flag& __flag, _Callable& __func)
if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
{
__call_once_param<_Callable> __p(__func);
- __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
+ std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
}
}
@@ -696,7 +693,7 @@ call_once(once_flag& __flag, const _Callable& __func)
if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
{
__call_once_param<const _Callable> __p(__func);
- __call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
+ std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
}
}
@@ -706,4 +703,10 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_MUTEX
diff --git a/libcxx/include/new b/libcxx/include/new
index ed95caed1c41..0c826f4a061c 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -89,10 +89,12 @@ void operator delete[](void* ptr, void*) noexcept;
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
#include <cstddef>
#include <cstdlib>
#include <exception>
-#include <type_traits>
#include <version>
#if defined(_LIBCPP_ABI_VCRUNTIME)
@@ -129,8 +131,8 @@ class _LIBCPP_EXCEPTION_ABI bad_alloc
{
public:
bad_alloc() _NOEXCEPT;
- virtual ~bad_alloc() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ ~bad_alloc() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
class _LIBCPP_EXCEPTION_ABI bad_array_new_length
@@ -138,15 +140,33 @@ class _LIBCPP_EXCEPTION_ABI bad_array_new_length
{
public:
bad_array_new_length() _NOEXCEPT;
- virtual ~bad_array_new_length() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ ~bad_array_new_length() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
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
+#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME
+
+// When _HAS_EXCEPTIONS == 0, these complete definitions are needed,
+// since they would normally be provided in vcruntime_exception.h
+class bad_alloc : public exception {
+public:
+ bad_alloc() noexcept : exception("bad allocation") {}
+
+private:
+ friend class bad_array_new_length;
+
+ bad_alloc(char const* const __message) noexcept : exception(__message) {}
+};
+
+class bad_array_new_length : public bad_alloc {
+public:
+ bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
+};
+#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
@@ -277,9 +297,9 @@ _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...);
+ return std::__libcpp_operator_delete(__ptr, __args...);
#else
- return __libcpp_operator_delete(__ptr, __size, __args...);
+ return std::__libcpp_operator_delete(__ptr, __size, __args...);
#endif
}
@@ -319,16 +339,26 @@ inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, s
// 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_alloc(std::size_t __alignment, std::size_t __size) {
+# if defined(_LIBCPP_MSVCRT_LIKE)
+ return ::_aligned_malloc(__size, __alignment);
+# elif _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)
+ // aligned_alloc() requires that __size is a multiple of __alignment,
+ // but for C++ [new.delete.general], only states "if the value of an
+ // alignment argument passed to any of these functions is not a valid
+ // alignment value, the behavior is undefined".
+ // To handle calls such as ::operator new(1, std::align_val_t(128)), we
+ // round __size up to the next multiple of __alignment.
+ size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1);
+ // Rounding up could have wrapped around to zero, so we have to add another
+ // max() ternary to the actual call site to avoid succeeded in that case.
+ return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
+# 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
@@ -347,7 +377,7 @@ _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" );
+ static_assert (!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void" );
return __builtin_launder(__p);
}
@@ -373,4 +403,8 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_NEW
diff --git a/libcxx/include/numbers b/libcxx/include/numbers
index 3c8527dfc2de..72034a6bc06b 100644
--- a/libcxx/include/numbers
+++ b/libcxx/include/numbers
@@ -59,9 +59,8 @@ namespace std::numbers {
*/
#include <__assert> // all public C++ headers provide the assertion handler
+#include <__concepts/arithmetic.h>
#include <__config>
-#include <concepts>
-#include <type_traits>
#include <version>
#if _LIBCPP_STD_VER > 17
@@ -131,4 +130,9 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 17
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_NUMBERS
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 057faf508e6b..100dbe1c3232 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -163,11 +163,6 @@ template<class T>
#include <__numeric/transform_inclusive_scan.h>
#include <__numeric/transform_reduce.h>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-# include <iterator>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -176,4 +171,11 @@ template<class T>
# include <__pstl_numeric>
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <iterator>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_NUMERIC
diff --git a/libcxx/include/optional b/libcxx/include/optional
index 349ceb5bc7f6..6a7e2d2941de 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -87,8 +87,8 @@ namespace std {
// 23.6.3.1, constructors
constexpr optional() noexcept;
constexpr optional(nullopt_t) noexcept;
- optional(const optional &);
- optional(optional &&) noexcept(see below);
+ constexpr optional(const optional &);
+ constexpr 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 &&...);
@@ -104,8 +104,8 @@ namespace std {
// 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
+ constexpr optional &operator=(const optional &);
+ constexpr optional &operator=(optional &&) noexcept(see below);
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
@@ -166,7 +166,7 @@ template<class T>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>
#include <__memory/construct_at.h>
-#include <__tuple>
+#include <__tuple_dir/sfinae_helpers.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
#include <__utility/move.h>
@@ -177,22 +177,9 @@ template<class T>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <atomic>
-# include <chrono>
-# include <climits>
-# include <concepts>
-# include <ctime>
-# include <iterator>
-# include <memory>
-# include <ratio>
-# include <tuple>
-# include <typeinfo>
-# include <utility>
-# include <variant>
-#endif
-
// standard-mandated includes
+
+// [optional.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -207,8 +194,8 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optiona
{
public:
// Get the key function ~bad_optional_access() into the dylib
- virtual ~bad_optional_access() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ ~bad_optional_access() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
} // namespace std
@@ -255,7 +242,7 @@ struct __optional_destruct_base<_Tp, false>
bool __engaged_;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__optional_destruct_base()
{
if (__engaged_)
__val_.~value_type();
@@ -280,7 +267,7 @@ struct __optional_destruct_base<_Tp, false>
#endif
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
{
if (__engaged_)
{
@@ -322,7 +309,7 @@ struct __optional_destruct_base<_Tp, true>
#endif
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
{
if (__engaged_)
{
@@ -367,7 +354,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_Args&&... __args)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_Args&&... __args)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
#if _LIBCPP_STD_VER > 17
@@ -380,7 +367,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
{
if (__opt.has_value())
__construct(_VSTD::forward<_That>(__opt).__get());
@@ -388,7 +375,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
{
if (this->__engaged_ == __opt.has_value())
{
@@ -417,14 +404,14 @@ struct __optional_storage_base<_Tp, true>
template <class _Up>
static constexpr bool __can_bind_reference() {
- using _RawUp = typename remove_reference<_Up>::type;
+ using _RawUp = __libcpp_remove_reference_t<_Up>;
using _UpPtr = _RawUp*;
- using _RawTp = typename remove_reference<_Tp>::type;
+ using _RawTp = __libcpp_remove_reference_t<_Tp>;
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
+ || is_same<_RawUp, reference_wrapper<__remove_const_t<_RawTp>>>::value
>;
return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value)
|| (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&
@@ -446,7 +433,7 @@ struct __optional_storage_base<_Tp, true>
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept { __value_ = nullptr; }
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; }
_LIBCPP_INLINE_VISIBILITY
constexpr bool has_value() const noexcept
@@ -462,7 +449,7 @@ struct __optional_storage_base<_Tp, true>
template <class _UArg>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_UArg&& __val)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
static_assert(__can_bind_reference<_UArg>(),
@@ -473,7 +460,7 @@ struct __optional_storage_base<_Tp, true>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
{
if (__opt.has_value())
__construct(_VSTD::forward<_That>(__opt).__get());
@@ -481,7 +468,7 @@ struct __optional_storage_base<_Tp, true>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
{
if (has_value() == __opt.has_value())
{
@@ -513,7 +500,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
__optional_copy_base() = default;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_base(const __optional_copy_base& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_base(const __optional_copy_base& __opt)
{
this->__construct_from(__opt);
}
@@ -544,7 +531,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
__optional_move_base(const __optional_move_base&) = default;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_base(__optional_move_base&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_move_base(__optional_move_base&& __opt)
noexcept(is_nothrow_move_constructible_v<value_type>)
{
this->__construct_from(_VSTD::move(__opt));
@@ -578,7 +565,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
__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)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
{
this->__assign_from(__opt);
return *this;
@@ -613,7 +600,7 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp
__optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 __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>)
{
@@ -652,9 +639,9 @@ public:
private:
// Disable the reference extension using this static assert.
- static_assert(!is_same_v<__uncvref_t<value_type>, in_place_t>,
+ static_assert(!is_same_v<__remove_cvref_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>,
+ static_assert(!is_same_v<__remove_cvref_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");
@@ -679,8 +666,8 @@ private:
};
template <class _Up>
using _CheckOptionalArgsCtor = _If<
- _IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&
- _IsNotSame<__uncvref_t<_Up>, optional>::value,
+ _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value &&
+ _IsNotSame<__remove_cvref_t<_Up>, optional>::value,
_CheckOptionalArgsConstructor,
__check_tuple_constructor_fail
>;
@@ -787,7 +774,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
{
this->__construct_from(__v);
}
@@ -795,7 +782,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(const optional<_Up>& __v)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v)
{
this->__construct_from(__v);
}
@@ -805,7 +792,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v)
{
this->__construct_from(_VSTD::move(__v));
}
@@ -813,7 +800,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v)
{
this->__construct_from(_VSTD::move(__v));
}
@@ -827,22 +814,22 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept
{
reset();
return *this;
}
- _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;
- _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&&) = default;
+ constexpr optional& operator=(const optional&) = default;
+ constexpr optional& operator=(optional&&) = default;
// LWG2756
template <class _Up = value_type,
class = enable_if_t<
_And<
- _IsNotSame<__uncvref_t<_Up>, optional>,
+ _IsNotSame<__remove_cvref_t<_Up>, optional>,
_Or<
- _IsNotSame<__uncvref_t<_Up>, value_type>,
+ _IsNotSame<__remove_cvref_t<_Up>, value_type>,
_Not<is_scalar<value_type>>
>,
is_constructible<value_type, _Up>,
@@ -850,7 +837,7 @@ public:
>::value>
>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
operator=(_Up&& __v)
{
if (this->has_value())
@@ -865,7 +852,7 @@ public:
_CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
operator=(const optional<_Up>& __v)
{
this->__assign_from(__v);
@@ -877,7 +864,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
operator=(optional<_Up>&& __v)
{
this->__assign_from(_VSTD::move(__v));
@@ -891,7 +878,7 @@ public:
>
>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
emplace(_Args&&... __args)
{
reset();
@@ -906,7 +893,7 @@ public:
>
>
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
reset();
@@ -915,7 +902,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt)
noexcept(is_nothrow_move_constructible_v<value_type> &&
is_nothrow_swappable_v<value_type>)
{
@@ -1198,8 +1185,8 @@ template<class _Tp>
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() ==
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() ==
+ std::declval<const _Up&>()), bool>,
bool
>
operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1214,8 +1201,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() !=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() !=
+ std::declval<const _Up&>()), bool>,
bool
>
operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1230,8 +1217,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <
+ std::declval<const _Up&>()), bool>,
bool
>
operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1246,8 +1233,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >
+ std::declval<const _Up&>()), bool>,
bool
>
operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1262,8 +1249,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <=
+ std::declval<const _Up&>()), bool>,
bool
>
operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1278,8 +1265,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >=
+ std::declval<const _Up&>()), bool>,
bool
>
operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1392,8 +1379,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() ==
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() ==
+ std::declval<const _Up&>()), bool>,
bool
>
operator==(const optional<_Tp>& __x, const _Up& __v)
@@ -1404,8 +1391,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() ==
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() ==
+ std::declval<const _Up&>()), bool>,
bool
>
operator==(const _Tp& __v, const optional<_Up>& __x)
@@ -1416,8 +1403,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() !=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() !=
+ std::declval<const _Up&>()), bool>,
bool
>
operator!=(const optional<_Tp>& __x, const _Up& __v)
@@ -1428,8 +1415,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() !=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() !=
+ std::declval<const _Up&>()), bool>,
bool
>
operator!=(const _Tp& __v, const optional<_Up>& __x)
@@ -1440,8 +1427,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <
+ std::declval<const _Up&>()), bool>,
bool
>
operator<(const optional<_Tp>& __x, const _Up& __v)
@@ -1452,8 +1439,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <
+ std::declval<const _Up&>()), bool>,
bool
>
operator<(const _Tp& __v, const optional<_Up>& __x)
@@ -1464,8 +1451,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <=
+ std::declval<const _Up&>()), bool>,
bool
>
operator<=(const optional<_Tp>& __x, const _Up& __v)
@@ -1476,8 +1463,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() <=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() <=
+ std::declval<const _Up&>()), bool>,
bool
>
operator<=(const _Tp& __v, const optional<_Up>& __x)
@@ -1488,8 +1475,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >
+ std::declval<const _Up&>()), bool>,
bool
>
operator>(const optional<_Tp>& __x, const _Up& __v)
@@ -1500,8 +1487,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >
+ std::declval<const _Up&>()), bool>,
bool
>
operator>(const _Tp& __v, const optional<_Up>& __x)
@@ -1512,8 +1499,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >=
+ std::declval<const _Up&>()), bool>,
bool
>
operator>=(const optional<_Tp>& __x, const _Up& __v)
@@ -1524,8 +1511,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<
- is_convertible_v<decltype(declval<const _Tp&>() >=
- declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(std::declval<const _Tp&>() >=
+ std::declval<const _Up&>()), bool>,
bool
>
operator>=(const _Tp& __v, const optional<_Up>& __x)
@@ -1535,7 +1522,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
enable_if_t<
is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
void
@@ -1587,4 +1574,18 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 14
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <climits>
+# include <concepts>
+# include <ctime>
+# include <iterator>
+# include <memory>
+# include <ratio>
+# include <tuple>
+# include <typeinfo>
+# include <utility>
+# include <variant>
+#endif
+
#endif // _LIBCPP_OPTIONAL
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 14b49d78cb03..4780c763ea03 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -165,16 +165,15 @@ basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, cons
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__memory/shared_ptr.h>
+#include <__memory/unique_ptr.h>
#include <bitset>
#include <ios>
#include <locale>
+#include <new>
#include <streambuf>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -197,7 +196,7 @@ public:
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
{ this->init(__sb); }
- virtual ~basic_ostream();
+ ~basic_ostream() override;
protected:
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream(basic_ostream&& __rhs);
@@ -413,7 +412,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -440,7 +439,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)
{
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());
+ const _Fp& __f = std::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)) :
@@ -469,7 +468,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::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);
}
@@ -496,7 +495,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)
{
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());
+ const _Fp& __f = std::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)) :
@@ -525,7 +524,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::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);
}
@@ -551,7 +550,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -577,7 +576,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -603,7 +602,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -629,7 +628,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -655,7 +654,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::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);
}
@@ -681,7 +680,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -707,7 +706,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -733,7 +732,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
if (__s)
{
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
- const _Fp& __f = use_facet<_Fp>(this->getloc());
+ const _Fp& __f = std::use_facet<_Fp>(this->getloc());
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
@@ -748,7 +747,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
}
template<class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
const _CharT* __str, size_t __len)
{
@@ -760,14 +759,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __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())
+ if (std::__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
@@ -782,14 +781,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
template<class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -801,14 +800,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
{
_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())
+ if (std::__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
@@ -822,35 +821,35 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
}
template<class _Traits>
-basic_ostream<char, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -875,14 +874,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
}
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())
+ if (std::__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
@@ -896,14 +895,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
}
template<class _Traits>
-basic_ostream<char, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
{
const char *__s = (const char *) __str;
@@ -911,7 +910,7 @@ operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
}
template<class _Traits>
-basic_ostream<char, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
{
const char *__s = (const char *) __str;
@@ -1032,7 +1031,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
}
template <class _CharT, class _Traits>
-inline
+_LIBCPP_HIDE_FROM_ABI inline
basic_ostream<_CharT, _Traits>&
endl(basic_ostream<_CharT, _Traits>& __os)
{
@@ -1042,7 +1041,7 @@ endl(basic_ostream<_CharT, _Traits>& __os)
}
template <class _CharT, class _Traits>
-inline
+_LIBCPP_HIDE_FROM_ABI inline
basic_ostream<_CharT, _Traits>&
ends(basic_ostream<_CharT, _Traits>& __os)
{
@@ -1051,7 +1050,7 @@ ends(basic_ostream<_CharT, _Traits>& __os)
}
template <class _CharT, class _Traits>
-inline
+_LIBCPP_HIDE_FROM_ABI inline
basic_ostream<_CharT, _Traits>&
flush(basic_ostream<_CharT, _Traits>& __os)
{
@@ -1064,7 +1063,7 @@ struct __is_ostreamable : false_type { };
template <class _Stream, class _Tp>
struct __is_ostreamable<_Stream, _Tp, decltype(
- declval<_Stream>() << declval<_Tp>(), void()
+ std::declval<_Stream>() << std::declval<_Tp>(), void()
)> : true_type { };
template <class _Stream, class _Tp, class = typename enable_if<
@@ -1087,7 +1086,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
}
template<class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
basic_string_view<_CharT, _Traits> __sv)
{
@@ -1114,7 +1113,7 @@ 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,
+ is_same<void, __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
basic_ostream<_CharT, _Traits>&
>::type
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
@@ -1123,12 +1122,12 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p
}
template <class _CharT, class _Traits, size_t _Size>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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'));
+ (std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
+ std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
#if _LIBCPP_STD_VER > 17
@@ -1189,4 +1188,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <iterator>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_OSTREAM
diff --git a/libcxx/include/queue b/libcxx/include/queue
index 9a5cfb39f24e..6c1b892efadc 100644
--- a/libcxx/include/queue
+++ b/libcxx/include/queue
@@ -231,11 +231,9 @@ template <class T, class Container, class Compare>
#include <vector>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-#endif
-
// standard-mandated includes
+
+// [queue.syn]
#include <compare>
#include <initializer_list>
@@ -384,6 +382,8 @@ public:
swap(c, __q.c);
}
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
+
template <class _T1, class _C1>
friend
_LIBCPP_INLINE_VISIBILITY
@@ -635,6 +635,8 @@ public:
void swap(priority_queue& __q)
_NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
__is_nothrow_swappable<value_compare>::value);
+
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
};
#if _LIBCPP_STD_VER >= 17
@@ -960,4 +962,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Comp
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+#endif
+
#endif // _LIBCPP_QUEUE
diff --git a/libcxx/include/random b/libcxx/include/random
index 41ee4d85fda3..5fe4906cb027 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -1718,25 +1718,28 @@ class piecewise_linear_distribution
#include <__random/weibull_distribution.h>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-#endif
-
// standard-mandated includes
-#include <initializer_list>
-#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
+// [rand.synopsis]
+#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <climits>
+# include <cmath>
+# include <concepts>
+# include <cstddef>
+# include <cstdint>
+# include <iosfwd>
+# include <limits>
+# include <numeric>
+# include <string>
+# include <type_traits>
+# include <vector>
+#endif
+
#endif // _LIBCPP_RANDOM
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index 82378a6b0daa..f999fa00c335 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -115,6 +115,27 @@ namespace std::ranges {
template<range R>
using borrowed_subrange_t = see below;
+ // [range.elements], elements view
+ template<input_range V, size_t N>
+ requires see below
+ class elements_view;
+
+ template<class T, size_t N>
+ inline constexpr bool enable_borrowed_range<elements_view<T, N>> =
+ enable_borrowed_range<T>;
+
+ template<class R>
+ using keys_view = elements_view<R, 0>;
+ template<class R>
+ using values_view = elements_view<R, 1>;
+
+ namespace views {
+ template<size_t N>
+ inline constexpr unspecified elements = unspecified;
+ inline constexpr auto keys = elements<0>;
+ inline constexpr auto values = elements<1>;
+ }
+
// [range.empty], empty view
template<class T>
requires is_object_v<T>
@@ -166,6 +187,18 @@ namespace std::ranges {
template<class T>
inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
+ // [range.drop.while], drop while view
+ template<view V, class Pred>
+ requires input_range<V> && is_object_v<Pred> &&
+ indirect_unary_predicate<const Pred, iterator_t<V>>
+ class drop_while_view;
+
+ template<class T, class Pred>
+ inline constexpr bool enable_borrowed_range<drop_while_view<T, Pred>> =
+ enable_borrowed_range<T>;
+
+ namespace views { inline constexpr unspecified drop_while = unspecified; }
+
// [range.transform], transform view
template<input_range V, copy_constructible F>
requires view<V> && is_object_v<F> &&
@@ -198,6 +231,14 @@ namespace std::ranges {
template<class T>
inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>;
+ // [range.take.while], take while view
+ template<view V, class Pred>
+ requires input_range<V> && is_object_v<Pred> &&
+ indirect_unary_predicate<const Pred, iterator_t<V>>
+ class take_while_view;
+
+ namespace views { inline constexpr unspecified take_while = unspecified; }
+
template<copy_constructible T>
requires is_object_v<T>
class single_view;
@@ -224,10 +265,30 @@ namespace std::ranges {
(forward_range<V> || tiny-range<Pattern>)
class lazy_split_view;
+ // [range.split], split view
+ template<forward_range V, forward_range Pattern>
+ requires view<V> && view<Pattern> &&
+ indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to>
+ class split_view;
+
namespace views {
inline constexpr unspecified lazy_split = unspecified;
+ inline constexpr unspecified split = unspecified;
}
+ // [range.istream], istream view
+ template<movable Val, class CharT, class Traits = char_traits<CharT>>
+ requires see below
+ class basic_istream_view;
+
+ template<class Val>
+ using istream_view = basic_istream_view<Val, char>;
+
+ template<class Val>
+ using wistream_view = basic_istream_view<Val, wchar_t>;
+
+ namespace views { template<class T> inline constexpr unspecified istream = unspecified; }
+
// [range.zip], zip view
template<input_range... Views>
requires (view<Views> && ...) && (sizeof...(Views) > 0)
@@ -238,6 +299,13 @@ namespace std::ranges {
(enable_borrowed_range<Views> && ...);
namespace views { inline constexpr unspecified zip = unspecified; } // C++2b
+
+ // [range.as.rvalue]
+ template <view V>
+ requires input_range<V>
+ class as_rvalue_view; // since C++23
+
+ namespace views { inline constexpr unspecified as_rvalue ) unspecified; } // since C++23
}
namespace std {
@@ -276,12 +344,15 @@ namespace std {
#include <__config>
#include <__ranges/access.h>
#include <__ranges/all.h>
+#include <__ranges/as_rvalue_view.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/drop_while_view.h>
+#include <__ranges/elements_view.h>
#include <__ranges/empty.h>
#include <__ranges/empty_view.h>
#include <__ranges/enable_borrowed_range.h>
@@ -296,19 +367,32 @@ namespace std {
#include <__ranges/reverse_view.h>
#include <__ranges/single_view.h>
#include <__ranges/size.h>
+#include <__ranges/split_view.h>
#include <__ranges/subrange.h>
#include <__ranges/take_view.h>
+#include <__ranges/take_while_view.h>
#include <__ranges/transform_view.h>
#include <__ranges/view_interface.h>
#include <__ranges/views.h>
#include <__ranges/zip_view.h>
-#include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized.
-#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_LOCALIZATION)
+#include <__ranges/istream_view.h>
+#endif
+
+// standard-mandated includes
+
+// [ranges.syn]
+#include <compare>
+#include <initializer_list>
+#include <iterator>
+
+// [tuple.helper]
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/ratio b/libcxx/include/ratio
index 5d7af88a2ac8..3969a392f3c6 100644
--- a/libcxx/include/ratio
+++ b/libcxx/include/ratio
@@ -79,9 +79,9 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__type_traits/integral_constant.h>
#include <climits>
#include <cstdint>
-#include <type_traits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -525,4 +525,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_RATIO
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 850fe099df1e..06c017fcce38 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -769,20 +769,17 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#include <__iterator/back_insert_iterator.h>
#include <__iterator/wrap_iter.h>
#include <__locale>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#include <__utility/swap.h>
+#include <cstring>
#include <deque>
-#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iterator>
-# include <utility>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -833,7 +830,7 @@ enum syntax_option_type
multiline = 1 << 10
};
-inline _LIBCPP_CONSTEXPR
+_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
syntax_option_type __get_grammar(syntax_option_type __g)
{
#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
@@ -1006,8 +1003,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error
public:
explicit regex_error(regex_constants::error_type __ecode);
regex_error(const regex_error&) _NOEXCEPT = default;
- virtual ~regex_error() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ ~regex_error() _NOEXCEPT override;
+ _LIBCPP_INLINE_VISIBILITY
regex_constants::error_type code() const {return __code_;}
};
@@ -1029,7 +1026,7 @@ public:
typedef _CharT char_type;
typedef basic_string<char_type> string_type;
typedef locale locale_type;
-#ifdef __BIONIC__
+#if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
// 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
@@ -1038,6 +1035,11 @@ public:
// 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.
+ // We also need this workaround for newlib since _NEWLIB_VERSION is not
+ // defined yet inside __config, so we can't set the
+ // _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE macro. Additionally, newlib is
+ // often used for space constrained environments, so it makes sense not to
+ // duplicate the ctype table.
typedef uint16_t char_class_type;
#else
typedef ctype_base::mask char_class_type;
@@ -1155,8 +1157,8 @@ template <class _CharT>
void
regex_traits<_CharT>::__init()
{
- __ct_ = &use_facet<ctype<char_type> >(__loc_);
- __col_ = &use_facet<collate<char_type> >(__loc_);
+ __ct_ = &std::use_facet<ctype<char_type> >(__loc_);
+ __col_ = &std::use_facet<collate<char_type> >(__loc_);
}
template <class _CharT>
@@ -1231,7 +1233,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
string_type __r;
if (!__s.empty())
{
- __r = __get_collation_name(__s.c_str());
+ __r = std::__get_collation_name(__s.c_str());
if (__r.empty() && __s.size() <= 2)
{
__r = __col_->transform(__s.data(), __s.data() + __s.size());
@@ -1294,7 +1296,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
{
string_type __s(__f, __l);
__ct_->tolower(&__s[0], &__s[0] + __s.size());
- return __get_classname(__s.c_str(), __icase);
+ return std::__get_classname(__s.c_str(), __icase);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -1355,7 +1357,7 @@ inline _LIBCPP_INLINE_VISIBILITY
unsigned char __to_lower(unsigned char __c)
{
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
- return c & 0xBF;
+ return __c & 0xBF;
#else
return __c | 0x20;
#endif
@@ -1444,12 +1446,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
__node() {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual ~__node() {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual void __exec(__state&) const {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual void __exec_split(bool, __state&) const {}
};
@@ -1507,7 +1509,7 @@ public:
explicit __owns_one_state(__node<_CharT>* __s)
: base(__s) {}
- virtual ~__owns_one_state();
+ ~__owns_one_state() override;
};
template <class _CharT>
@@ -2092,7 +2094,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const
}
else if (__multiline_ &&
!__s.__at_first_ &&
- __is_eol(*_VSTD::prev(__s.__current_)))
+ std::__is_eol(*_VSTD::prev(__s.__current_)))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -2134,7 +2136,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
- else if (__multiline_ && __is_eol(*__s.__current_))
+ else if (__multiline_ && std::__is_eol(*__s.__current_))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -2196,7 +2198,7 @@ public:
__match_any_but_newline(__node<_CharT>* __s)
: base(__s) {}
- virtual void __exec(__state&) const;
+ void __exec(__state&) const override;
};
template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
@@ -2403,7 +2405,7 @@ public:
for (size_t __i = 0; __i < __e.size(); ++__i)
__e[__i] = __traits_.translate(__e[__i]);
}
- __ranges_.push_back(make_pair(
+ __ranges_.push_back(std::make_pair(
__traits_.transform(__b.begin(), __b.end()),
__traits_.transform(__e.begin(), __e.end())));
}
@@ -2416,20 +2418,20 @@ public:
__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)));
+ __ranges_.push_back(std::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)));
+ __digraphs_.push_back(std::make_pair(__traits_.translate_nocase(__c1),
+ __traits_.translate_nocase(__c2)));
else if (__collate_)
- __digraphs_.push_back(make_pair(__traits_.translate(__c1),
- __traits_.translate(__c2)));
+ __digraphs_.push_back(std::make_pair(__traits_.translate(__c1),
+ __traits_.translate(__c2)));
else
- __digraphs_.push_back(make_pair(__c1, __c2));
+ __digraphs_.push_back(std::make_pair(__c1, __c2));
}
_LIBCPP_INLINE_VISIBILITY
void __add_equivalence(const string_type& __s)
@@ -5521,7 +5523,7 @@ public:
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(),
+ format(std::back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
__flags);
return __r;
}
@@ -5531,7 +5533,7 @@ public:
regex_constants::match_flag_type __flags = regex_constants::format_default) const
{
string_type __r;
- format(back_inserter(__r), __fmt,
+ format(std::back_inserter(__r), __fmt,
__fmt + char_traits<char_type>::length(__fmt), __flags);
return __r;
}
@@ -5732,7 +5734,7 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
}
template <class _BidirectionalIterator, class _Allocator>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
const match_results<_BidirectionalIterator, _Allocator>& __y)
{
@@ -6224,7 +6226,7 @@ regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
// regex_match
template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
match_results<_BidirectionalIterator, _Allocator>& __m,
const basic_regex<_CharT, _Traits>& __e,
@@ -6737,7 +6739,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
template <class _OutputIterator, class _BidirectionalIterator,
class _Traits, class _CharT>
-_OutputIterator
+_LIBCPP_HIDE_FROM_ABI _OutputIterator
regex_replace(_OutputIterator __output_iter,
_BidirectionalIterator __first, _BidirectionalIterator __last,
const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
@@ -6792,7 +6794,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
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,
+ _VSTD::regex_replace(std::back_inserter(__r), __s.begin(), __s.end(), __e,
__fmt.c_str(), __flags);
return __r;
}
@@ -6805,7 +6807,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
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,
+ _VSTD::regex_replace(std::back_inserter(__r), __s.begin(), __s.end(), __e,
__fmt, __flags);
return __r;
}
@@ -6819,7 +6821,7 @@ regex_replace(const _CharT* __s,
regex_constants::match_flag_type __flags = regex_constants::match_default)
{
basic_string<_CharT> __r;
- _VSTD::regex_replace(back_inserter(__r), __s,
+ _VSTD::regex_replace(std::back_inserter(__r), __s,
__s + char_traits<_CharT>::length(__s), __e,
__fmt.c_str(), __flags);
return __r;
@@ -6834,7 +6836,7 @@ regex_replace(const _CharT* __s,
regex_constants::match_flag_type __flags = regex_constants::match_default)
{
basic_string<_CharT> __r;
- _VSTD::regex_replace(back_inserter(__r), __s,
+ _VSTD::regex_replace(std::back_inserter(__r), __s,
__s + char_traits<_CharT>::length(__s), __e,
__fmt, __flags);
return __r;
@@ -6842,6 +6844,33 @@ regex_replace(const _CharT* __s,
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _BidirT>
+using match_results = std::match_results<_BidirT, polymorphic_allocator<std::sub_match<_BidirT>>>;
+
+using cmatch = match_results<const char*>;
+using smatch = match_results<std::pmr::string::const_iterator>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wcmatch = match_results<const wchar_t*>;
+using wsmatch = match_results<std::pmr::wstring::const_iterator>;
+#endif
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <concepts>
+# include <iosfwd>
+# include <iterator>
+# include <new>
+# include <typeinfo>
+# include <utility>
+#endif
+
#endif // _LIBCPP_REGEX
diff --git a/libcxx/include/scoped_allocator b/libcxx/include/scoped_allocator
index cf82affba78f..461c67e9b656 100644
--- a/libcxx/include/scoped_allocator
+++ b/libcxx/include/scoped_allocator
@@ -111,8 +111,19 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+#include <__memory/allocator_traits.h>
+#include <__memory/uses_allocator_construction.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/remove_reference.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
-#include <memory>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <__utility/piecewise_construct.h>
+#include <tuple>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -352,7 +363,7 @@ protected:
// __outermost
template <class _Alloc>
-decltype(declval<_Alloc>().outer_allocator(), true_type())
+decltype(std::declval<_Alloc>().outer_allocator(), true_type())
__has_outer_allocator_test(_Alloc&& __a);
template <class _Alloc>
@@ -363,7 +374,7 @@ template <class _Alloc>
struct __has_outer_allocator
: public common_type
<
- decltype(__has_outer_allocator_test(declval<_Alloc&>()))
+ decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))
>::type
{
};
@@ -379,10 +390,10 @@ struct __outermost
template <class _Alloc>
struct __outermost<_Alloc, true>
{
- typedef typename remove_reference
+ typedef __libcpp_remove_reference_t
<
- decltype(declval<_Alloc>().outer_allocator())
- >::type _OuterAlloc;
+ decltype(std::declval<_Alloc>().outer_allocator())
+ > _OuterAlloc;
typedef typename __outermost<_OuterAlloc>::type type;
_LIBCPP_INLINE_VISIBILITY
type& operator()(_Alloc& __a) const _NOEXCEPT
@@ -501,6 +512,18 @@ public:
size_type max_size() const
{return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
+#if _LIBCPP_STD_VER >= 20
+ template <class _Type, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
+ using _OM = __outermost<outer_allocator_type>;
+ std::apply(
+ [__ptr, this](auto&&... __newargs) {
+ allocator_traits<typename _OM::type>::construct(
+ _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
+ },
+ std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
+ }
+#else
template <class _Tp, class... _Args>
_LIBCPP_INLINE_VISIBILITY
void construct(_Tp* __p, _Args&& ...__args)
@@ -555,6 +578,7 @@ public:
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
}
+#endif
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
@@ -692,4 +716,18 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <atomic>
+# include <climits>
+# include <concepts>
+# include <cstring>
+# include <ctime>
+# include <iterator>
+# include <memory>
+# include <ratio>
+# include <stdexcept>
+# include <type_traits>
+# include <variant>
+#endif
+
#endif // _LIBCPP_SCOPED_ALLOCATOR
diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 228cf773f0fd..ddccb28dab47 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -80,31 +80,31 @@ functions. It avoids contention against users' own use of those facilities.
class __atomic_semaphore_base
{
- __atomic_base<ptrdiff_t> __a;
+ __atomic_base<ptrdiff_t> __a_;
public:
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
+ 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))
+ if(0 < __a_.fetch_add(__update, memory_order_release))
;
else if(__update > 1)
- __a.notify_all();
+ __a_.notify_all();
else
- __a.notify_one();
+ __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);
+ 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);
+ __cxx_atomic_wait(&__a_.__a_, __test_fn);
}
template <class Rep, class Period>
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
@@ -113,16 +113,16 @@ public:
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);
+ return std::__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);
+ 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))
+ if (__a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
return true;
}
}
@@ -133,7 +133,7 @@ public:
template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
class counting_semaphore
{
- __atomic_semaphore_base __semaphore;
+ __atomic_semaphore_base __semaphore_;
public:
static constexpr ptrdiff_t max() noexcept {
@@ -141,7 +141,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { }
+ constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore_(__count) { }
~counting_semaphore() = default;
counting_semaphore(const counting_semaphore&) = delete;
@@ -150,23 +150,23 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void release(ptrdiff_t __update = 1)
{
- __semaphore.release(__update);
+ __semaphore_.release(__update);
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void acquire()
{
- __semaphore.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));
+ 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();
+ return __semaphore_.try_acquire();
}
template <class Clock, class Duration>
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/set b/libcxx/include/set
index da62f6f5ca5b..1154c4e9509c 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -480,16 +480,14 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
+#include <__memory/allocator.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__node_handle>
#include <__tree>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -533,6 +531,10 @@ private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
__base __tree_;
public:
@@ -1066,6 +1068,10 @@ private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
__base __tree_;
public:
@@ -1578,4 +1584,22 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _KeyT, class _CompareT = std::less<_KeyT>>
+using set = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
+
+template <class _KeyT, class _CompareT = std::less<_KeyT>>
+using multiset = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_SET
diff --git a/libcxx/include/setjmp.h b/libcxx/include/setjmp.h
index de4f9edf4886..f4a2bbcb0bd3 100644
--- a/libcxx/include/setjmp.h
+++ b/libcxx/include/setjmp.h
@@ -31,7 +31,9 @@ void longjmp(jmp_buf env, int val);
# pragma GCC system_header
#endif
-#include_next <setjmp.h>
+#if __has_include_next(<setjmp.h>)
+# include_next <setjmp.h>
+#endif
#ifdef __cplusplus
diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex
index f85cf6ec4c4f..6919898f66f4 100644
--- a/libcxx/include/shared_mutex
+++ b/libcxx/include/shared_mutex
@@ -180,23 +180,23 @@ __shared_mutex_base
#if _LIBCPP_STD_VER > 14
class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex
{
- __shared_mutex_base __base;
+ __shared_mutex_base __base_;
public:
- _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base() {}
+ _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(); }
+ _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(); }
+ _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(); }
@@ -206,7 +206,7 @@ public:
class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex
{
- __shared_mutex_base __base;
+ __shared_mutex_base __base_;
public:
shared_timed_mutex();
_LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
@@ -252,30 +252,30 @@ 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_)
+ 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)
+ 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_)
+ __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)
+ 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();
+ __base_.__state_ &= ~__base_.__write_entered_;
+ __base_.__gate1_.notify_all();
return false;
}
}
@@ -288,22 +288,22 @@ 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_)
+ 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_)
+ 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;
+ unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1;
+ __base_.__state_ &= ~__base_.__n_readers_;
+ __base_.__state_ |= __num_readers;
return true;
}
@@ -432,6 +432,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
template <class _Mutex>
void
diff --git a/libcxx/include/source_location b/libcxx/include/source_location
new file mode 100644
index 000000000000..4c4a09618ada
--- /dev/null
+++ b/libcxx/include/source_location
@@ -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_SOURCE_LOCATION
+#define _LIBCPP_SOURCE_LOCATION
+
+/* source_location synopsis
+
+namespace std {
+ struct source_location {
+ static consteval source_location current() noexcept;
+ constexpr source_location() noexcept;
+
+ constexpr uint_least32_t line() const noexcept;
+ constexpr uint_least32_t column() const noexcept;
+ constexpr const char* file_name() const noexcept;
+ constexpr const char* function_name() const noexcept;
+ };
+}
+*/
+
+#include <__config>
+#include <cstdint>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
+
+class source_location {
+ // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column
+ // are hard-coded in the compiler and must not be changed here.
+ struct __impl {
+ const char* _M_file_name;
+ const char* _M_function_name;
+ unsigned _M_line;
+ unsigned _M_column;
+ };
+ const __impl* __ptr_ = nullptr;
+ // GCC returns the type 'const void*' from the builtin, while clang returns
+ // `const __impl*`. Per C++ [expr.const], casts from void* are not permitted
+ // in constant evaluation, so we don't want to use `void*` as the argument
+ // type unless the builtin returned that, anyhow, and the invalid cast is
+ // unavoidable.
+ using __bsl_ty = decltype(__builtin_source_location());
+
+public:
+ // The defaulted __ptr argument is necessary so that the builtin is evaluated
+ // in the context of the caller. An explicit value should never be provided.
+ static consteval source_location current(__bsl_ty __ptr = __builtin_source_location()) noexcept {
+ source_location __sl;
+ __sl.__ptr_ = static_cast<const __impl*>(__ptr);
+ return __sl;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr source_location() noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t line() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_line : 0;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t column() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_column : 0;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* file_name() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_file_name : "";
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* function_name() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_function_name : "";
+ }
+};
+
+#endif // _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SOURCE_LOCATION
diff --git a/libcxx/include/span b/libcxx/include/span
index 00793a210cbe..23af04f38839 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -148,11 +148,6 @@ template<class R>
#include <type_traits> // for remove_cv, etc
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -185,23 +180,6 @@ 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_INCOMPLETE_RANGES)
-// This is a temporary workaround until we ship <ranges> -- we've unfortunately been
-// shipping <span> before its API was finalized, and we used to provide a constructor
-// from container types that had the requirements below. To avoid breaking code that
-// has started relying on the range-based constructor until we ship all of <ranges>,
-// we emulate the constructor requirements like this.
-template <class _Range, class _ElementType>
-concept __span_compatible_range =
- !__is_std_span<remove_cvref_t<_Range>>::value &&
- !__is_std_array<remove_cvref_t<_Range>>::value &&
- !is_array_v<remove_cvref_t<_Range>> &&
- requires (_Range&& __r) {
- data(std::forward<_Range>(__r));
- size(std::forward<_Range>(__r));
- } &&
- is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
-#else
template <class _Range, class _ElementType>
concept __span_compatible_range =
ranges::contiguous_range<_Range> &&
@@ -211,7 +189,6 @@ concept __span_compatible_range =
!__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(*)[]>;
-#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
template <class _From, class _To>
concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
@@ -234,7 +211,7 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
using iterator = __bounded_iter<pointer>;
#else
using iterator = __wrap_iter<pointer>;
@@ -245,7 +222,7 @@ public:
// [span.cons], span constructors, copy, assignment, and destructor
template <size_t _Sz = _Extent> requires(_Sz == 0)
- _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data_{nullptr} {}
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
@@ -253,61 +230,46 @@ public:
template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_It __first, size_type __count)
- : __data{_VSTD::to_address(__first)} {
+ : __data_{_VSTD::to_address(__first)} {
(void)__count;
_LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
}
template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
+ 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");
}
- _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data_{__arr} {}
template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
+ constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data_{__arr.data()} {}
template <class _OtherElementType>
requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
+ constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data_{__arr.data()} {}
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
- template <class _Container>
- requires __span_compatible_range<_Container, element_type>
- _LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(_Container& __c) : __data{std::data(__c)} {
- _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
- }
- template <class _Container>
- requires __span_compatible_range<const _Container, element_type>
- _LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {
- _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
- }
-#else
template <__span_compatible_range<element_type> _Range>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
+ constexpr explicit span(_Range&& __r) : __data_{ranges::data(__r)} {
_LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
}
-#endif
template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const span<_OtherElementType, _Extent>& __other)
- : __data{__other.data()} {}
+ : __data_{__other.data()} {}
template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
- : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
+ : __data_{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
// ~span() noexcept = default;
@@ -374,33 +336,33 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
_LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
- return __data[__idx];
+ return __data_[__idx];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
{
_LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
- return __data[0];
+ 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];
+ return __data_[size()-1];
}
- _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
+ _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data_; }
// [span.iter], span iterator support
_LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
return std::__make_bounded_iter(data(), data(), data() + size());
#else
return iterator(this, data());
#endif
}
_LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
return std::__make_bounded_iter(data() + size(), data(), data() + size());
#else
return iterator(this, data() + size());
@@ -416,7 +378,7 @@ public:
{ return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; }
private:
- pointer __data;
+ pointer __data_;
};
@@ -432,7 +394,7 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
using iterator = __bounded_iter<pointer>;
#else
using iterator = __wrap_iter<pointer>;
@@ -442,7 +404,7 @@ public:
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} {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data_{nullptr}, __size_{0} {}
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
@@ -450,45 +412,35 @@ public:
template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_It __first, size_type __count)
- : __data{_VSTD::to_address(__first)}, __size{__count} {}
+ : __data_{_VSTD::to_address(__first)}, __size_{__count} {}
template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
- _LIBCPP_INLINE_VISIBILITY
- constexpr span(_It __first, _End __last)
- : __data(_VSTD::to_address(__first)), __size(__last - __first) {}
+ _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last)
+ : __data_(_VSTD::to_address(__first)), __size_(__last - __first) {
+ _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");
+ }
template <size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
+ constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data_{__arr}, __size_{_Sz} {}
template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+ constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data_{__arr.data()}, __size_{_Sz} {}
template <class _OtherElementType, size_t _Sz>
requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+ constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data_{__arr.data()}, __size_{_Sz} {}
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
- template <class _Container>
- requires __span_compatible_range<_Container, element_type>
- _LIBCPP_INLINE_VISIBILITY
- constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
- template <class _Container>
- requires __span_compatible_range<const _Container, element_type>
- _LIBCPP_INLINE_VISIBILITY
- constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
-#else
template <__span_compatible_range<element_type> _Range>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
-#endif
+ constexpr span(_Range&& __r) : __data_(ranges::data(__r)), __size_{ranges::size(__r)} {}
template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
- : __data{__other.data()}, __size{__other.size()} {}
+ : __data_{__other.data()}, __size_{__other.size()} {}
// ~span() noexcept = default;
@@ -543,41 +495,41 @@ public:
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 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>::operator[](index): index out of range");
- return __data[__idx];
+ return __data_[__idx];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
{
_LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
- return __data[0];
+ return __data_[0];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
{
_LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
- return __data[size()-1];
+ return __data_[size()-1];
}
- _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
+ _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data_; }
// [span.iter], span iterator support
_LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
return std::__make_bounded_iter(data(), data(), data() + size());
#else
return iterator(this, data());
#endif
}
_LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
-#ifdef _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
return std::__make_bounded_iter(data() + size(), data(), data() + size());
#else
return iterator(this, data() + size());
@@ -593,8 +545,8 @@ public:
{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
private:
- pointer __data;
- size_type __size;
+ pointer __data_;
+ size_type __size_;
};
template <class _Tp, size_t _Extent>
@@ -628,16 +580,8 @@ template<class _Tp, size_t _Sz>
template<class _Tp, size_t _Sz>
span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-template<class _Container>
- span(_Container&) -> span<typename _Container::value_type>;
-
-template<class _Container>
- span(const _Container&) -> span<const typename _Container::value_type>;
-#else
template<ranges::contiguous_range _Range>
span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
-#endif
#endif // _LIBCPP_STD_VER > 17
@@ -645,4 +589,10 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_SPAN
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 602a1b55b4a9..78cc28a50282 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -11,8 +11,9 @@
#define _LIBCPP_SSTREAM
/*
- sstream synopsis
+ sstream synopsis [sstream.syn]
+// Class template basic_stringbuf [stringbuf]
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringbuf
: public basic_streambuf<charT, traits>
@@ -25,7 +26,7 @@ public:
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
- // 27.8.1.1 [stringbuf.cons], constructors:
+ // [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
@@ -33,16 +34,16 @@ public:
ios_base::openmode which = ios_base::in | ios_base::out);
basic_stringbuf(basic_stringbuf&& rhs);
- // 27.8.1.2 Assign and swap:
+ // [stringbuf.assign] Assign and swap:
basic_stringbuf& operator=(basic_stringbuf&& rhs);
void swap(basic_stringbuf& rhs);
- // 27.8.1.3 Get and set:
+ // [stringbuf.members] Member functions:
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:
+ // [stringbuf.virtuals] 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());
@@ -53,6 +54,7 @@ protected:
ios_base::openmode which = ios_base::in | ios_base::out);
};
+// [stringbuf.assign] non member swap
template <class charT, class traits, class Allocator>
void swap(basic_stringbuf<charT, traits, Allocator>& x,
basic_stringbuf<charT, traits, Allocator>& y);
@@ -60,6 +62,7 @@ template <class charT, class traits, class Allocator>
typedef basic_stringbuf<char> stringbuf;
typedef basic_stringbuf<wchar_t> wstringbuf;
+// Class template basic_istringstream [istringstream]
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_istringstream
: public basic_istream<charT, traits>
@@ -72,7 +75,7 @@ public:
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
- // 27.8.2.1 Constructors:
+ // [istringstream.cons] 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
@@ -81,11 +84,11 @@ public:
ios_base::openmode which = ios_base::in);
basic_istringstream(basic_istringstream&& rhs);
- // 27.8.2.2 Assign and swap:
+ // [istringstream.assign] Assign and swap:
basic_istringstream& operator=(basic_istringstream&& rhs);
void swap(basic_istringstream& rhs);
- // 27.8.2.3 Members:
+ // [istringstream.members] Member functions:
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);
@@ -98,6 +101,7 @@ template <class charT, class traits, class Allocator>
typedef basic_istringstream<char> istringstream;
typedef basic_istringstream<wchar_t> wistringstream;
+// Class template basic_ostringstream [ostringstream]
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_ostringstream
: public basic_ostream<charT, traits>
@@ -111,7 +115,7 @@ public:
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
- // 27.8.3.1 Constructors/destructor:
+ // [ostringstream.cons] Constructors:
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
@@ -120,11 +124,11 @@ public:
ios_base::openmode which = ios_base::out);
basic_ostringstream(basic_ostringstream&& rhs);
- // 27.8.3.2 Assign/swap:
+ // [ostringstream.assign] Assign and swap:
basic_ostringstream& operator=(basic_ostringstream&& rhs);
void swap(basic_ostringstream& rhs);
- // 27.8.3.3 Members:
+ // [ostringstream.members] Member functions:
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);
@@ -137,6 +141,7 @@ template <class charT, class traits, class Allocator>
typedef basic_ostringstream<char> ostringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
+// Class template basic_stringstream [stringstream]
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringstream
: public basic_iostream<charT, traits>
@@ -150,7 +155,7 @@ public:
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
- // constructors/destructor
+ // [stringstream.cons] constructors
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
@@ -159,11 +164,11 @@ public:
ios_base::openmode which = ios_base::out|ios_base::in);
basic_stringstream(basic_stringstream&& rhs);
- // 27.8.5.1 Assign/swap:
+ // [stringstream.assign] Assign and swap:
basic_stringstream& operator=(basic_stringstream&& rhs);
void swap(basic_stringstream& rhs);
- // Members:
+ // [stringstream.members] Member functions:
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);
@@ -198,7 +203,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-// basic_stringbuf
+// Class template basic_stringbuf [stringbuf]
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TEMPLATE_VIS basic_stringbuf
@@ -221,7 +226,7 @@ private:
ios_base::openmode __mode_;
public:
- // 30.8.2.1 [stringbuf.cons], constructors
+ // [stringbuf.cons] constructors:
_LIBCPP_INLINE_VISIBILITY
basic_stringbuf()
: __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
@@ -240,24 +245,24 @@ public:
basic_stringbuf(basic_stringbuf&& __rhs);
- // 27.8.1.2 Assign and swap:
+ // [stringbuf.assign] Assign and swap:
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
void swap(basic_stringbuf& __rhs);
- // 27.8.1.3 Get and set:
+ // [stringbuf.members] Member functions:
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) {
+ // [stringbuf.virtuals] Overridden virtual functions:
+ int_type underflow() override;
+ int_type pbackfail(int_type __c = traits_type::eof()) override;
+ int_type overflow (int_type __c = traits_type::eof()) override;
+ pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __wch = ios_base::in | ios_base::out) override;
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL
+ pos_type seekpos(pos_type __sp,
+ ios_base::openmode __wch = ios_base::in | ios_base::out) override {
return seekoff(__sp, ios_base::beg, __wch);
}
};
@@ -619,7 +624,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
return pos_type(__noff);
}
-// basic_istringstream
+// Class template basic_istringstream [istringstream]
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TEMPLATE_VIS basic_istringstream
@@ -639,7 +644,7 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 30.8.3.1 [istringstream.cons], constructors
+ // [istringstream.cons] Constructors:
_LIBCPP_INLINE_VISIBILITY
basic_istringstream()
: basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
@@ -663,7 +668,7 @@ public:
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
- // 27.8.2.2 Assign and swap:
+ // [istringstream.assign] Assign and swap:
basic_istringstream& operator=(basic_istringstream&& __rhs) {
basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
@@ -675,7 +680,7 @@ public:
__sb_.swap(__rhs.__sb_);
}
- // 27.8.2.3 Members:
+ // [istringstream.members] Member functions:
_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_);
@@ -699,7 +704,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
__x.swap(__y);
}
-// basic_ostringstream
+// Class template basic_ostringstream [ostringstream]
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TEMPLATE_VIS basic_ostringstream
@@ -719,7 +724,7 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 30.8.4.1 [ostringstream.cons], constructors
+ // [ostringstream.cons] Constructors:
_LIBCPP_INLINE_VISIBILITY
basic_ostringstream()
: basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
@@ -743,7 +748,7 @@ public:
basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
- // 27.8.2.2 Assign and swap:
+ // [ostringstream.assign] Assign and swap:
basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
@@ -756,7 +761,7 @@ public:
__sb_.swap(__rhs.__sb_);
}
- // 27.8.2.3 Members:
+ // [ostringstream.members] Member functions:
_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_);
@@ -780,7 +785,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
__x.swap(__y);
}
-// basic_stringstream
+// Class template basic_stringstream [stringstream]
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TEMPLATE_VIS basic_stringstream
@@ -800,7 +805,7 @@ private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
- // 30.8.5.1 [stringstream.cons], constructors
+ // [stringstream.cons] constructors
_LIBCPP_INLINE_VISIBILITY
basic_stringstream()
: basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
@@ -824,7 +829,7 @@ public:
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
- // 27.8.2.2 Assign and swap:
+ // [stringstream.assign] Assign and swap:
basic_stringstream& operator=(basic_stringstream&& __rhs) {
basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
__sb_ = _VSTD::move(__rhs.__sb_);
@@ -836,7 +841,7 @@ public:
__sb_.swap(__rhs.__sb_);
}
- // 27.8.2.3 Members:
+ // [stringstream.members] Member functions:
_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_);
@@ -871,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_SSTREAM
diff --git a/libcxx/include/stack b/libcxx/include/stack
index 86435c4559de..d653d1bc7e49 100644
--- a/libcxx/include/stack
+++ b/libcxx/include/stack
@@ -107,11 +107,9 @@ template <class T, class Container>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-#endif
-
// standard-mandated includes
+
+// [stack.syn]
#include <compare>
#include <initializer_list>
@@ -257,6 +255,8 @@ public:
swap(c, __s.c);
}
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
+
template <class T1, class _C1>
friend
bool
@@ -363,4 +363,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+#endif
+
#endif // _LIBCPP_STACK
diff --git a/libcxx/include/stdatomic.h b/libcxx/include/stdatomic.h
index d9550c44061c..ff2a5682f5bb 100644
--- a/libcxx/include/stdatomic.h
+++ b/libcxx/include/stdatomic.h
@@ -121,7 +121,7 @@ using std::atomic_signal_fence // see below
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 20
+#if defined(__cplusplus) && _LIBCPP_STD_VER > 20
#include <atomic>
#include <version>
@@ -230,6 +230,6 @@ using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
# include_next <stdatomic.h>
# endif
-#endif // _LIBCPP_STD_VER > 20
+#endif // defined(__cplusplus) && _LIBCPP_STD_VER > 20
#endif // _LIBCPP_STDATOMIC_H
diff --git a/libcxx/include/stdbool.h b/libcxx/include/stdbool.h
index 0bc1aa8304ad..74869b46d561 100644
--- a/libcxx/include/stdbool.h
+++ b/libcxx/include/stdbool.h
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+
#ifndef _LIBCPP_STDBOOL_H
#define _LIBCPP_STDBOOL_H
@@ -24,7 +25,9 @@ Macros:
# pragma GCC system_header
#endif
-#include_next <stdbool.h>
+#if __has_include_next(<stdbool.h>)
+# include_next <stdbool.h>
+#endif
#ifdef __cplusplus
#undef bool
diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h
index 19e344f2a000..f1725db06212 100644
--- a/libcxx/include/stddef.h
+++ b/libcxx/include/stddef.h
@@ -42,7 +42,9 @@ Types:
# pragma GCC system_header
#endif
-#include_next <stddef.h>
+# if __has_include_next(<stddef.h>)
+# include_next <stddef.h>
+# endif
#ifdef __cplusplus
typedef decltype(nullptr) nullptr_t;
diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept
index ee5a296cd930..68de6ced174a 100644
--- a/libcxx/include/stdexcept
+++ b/libcxx/include/stdexcept
@@ -87,9 +87,9 @@ public:
logic_error(const logic_error&) _NOEXCEPT;
logic_error& operator=(const logic_error&) _NOEXCEPT;
- virtual ~logic_error() _NOEXCEPT;
+ ~logic_error() _NOEXCEPT override;
- virtual const char* what() const _NOEXCEPT;
+ const char* what() const _NOEXCEPT override;
#else
public:
explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string
@@ -110,9 +110,9 @@ public:
runtime_error(const runtime_error&) _NOEXCEPT;
runtime_error& operator=(const runtime_error&) _NOEXCEPT;
- virtual ~runtime_error() _NOEXCEPT;
+ ~runtime_error() _NOEXCEPT override;
- virtual const char* what() const _NOEXCEPT;
+ const char* what() const _NOEXCEPT override;
#else
public:
explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string
@@ -129,7 +129,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
domain_error(const domain_error&) _NOEXCEPT = default;
- virtual ~domain_error() _NOEXCEPT;
+ ~domain_error() _NOEXCEPT override;
#endif
};
@@ -142,7 +142,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
invalid_argument(const invalid_argument&) _NOEXCEPT = default;
- virtual ~invalid_argument() _NOEXCEPT;
+ ~invalid_argument() _NOEXCEPT override;
#endif
};
@@ -154,7 +154,7 @@ public:
_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;
+ ~length_error() _NOEXCEPT override;
#endif
};
@@ -167,7 +167,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
out_of_range(const out_of_range&) _NOEXCEPT = default;
- virtual ~out_of_range() _NOEXCEPT;
+ ~out_of_range() _NOEXCEPT override;
#endif
};
@@ -180,7 +180,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
range_error(const range_error&) _NOEXCEPT = default;
- virtual ~range_error() _NOEXCEPT;
+ ~range_error() _NOEXCEPT override;
#endif
};
@@ -193,7 +193,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
overflow_error(const overflow_error&) _NOEXCEPT = default;
- virtual ~overflow_error() _NOEXCEPT;
+ ~overflow_error() _NOEXCEPT override;
#endif
};
@@ -206,7 +206,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
underflow_error(const underflow_error&) _NOEXCEPT = default;
- virtual ~underflow_error() _NOEXCEPT;
+ ~underflow_error() _NOEXCEPT override;
#endif
};
diff --git a/libcxx/include/stdint.h b/libcxx/include/stdint.h
index ee71f62ab095..fa7b011c71ae 100644
--- a/libcxx/include/stdint.h
+++ b/libcxx/include/stdint.h
@@ -120,6 +120,8 @@ Macros:
# define __STDC_CONSTANT_MACROS
#endif
-#include_next <stdint.h>
+#if __has_include_next(<stdint.h>)
+# include_next <stdint.h>
+#endif
#endif // _LIBCPP_STDINT_H
diff --git a/libcxx/include/stdio.h b/libcxx/include/stdio.h
index ad1b4c05f1fa..cea43aa7680b 100644
--- a/libcxx/include/stdio.h
+++ b/libcxx/include/stdio.h
@@ -104,7 +104,9 @@ void perror(const char* s);
# pragma GCC system_header
#endif
-#include_next <stdio.h>
+# if __has_include_next(<stdio.h>)
+# include_next <stdio.h>
+# endif
#ifdef __cplusplus
diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h
index e4dce9c54546..4dd3a9c14ab0 100644
--- a/libcxx/include/stdlib.h
+++ b/libcxx/include/stdlib.h
@@ -90,7 +90,9 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
# pragma GCC system_header
#endif
-#include_next <stdlib.h>
+# if __has_include_next(<stdlib.h>)
+# include_next <stdlib.h>
+# endif
#ifdef __cplusplus
extern "C++" {
@@ -108,24 +110,24 @@ extern "C++" {
// 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 {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
return __builtin_labs(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
+_LIBCPP_NODISCARD_EXT 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 {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
}
-inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
return __builtin_fabs(__lcpp_x);
}
-inline _LIBCPP_INLINE_VISIBILITY long double
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long double
abs(long double __lcpp_x) _NOEXCEPT {
return __builtin_fabsl(__lcpp_x);
}
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index 53a71720f11a..d473df103475 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -489,10 +489,12 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
}
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
-extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
-
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
+#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/string b/libcxx/include/string
index 3723dc8a3938..9f5838d42583 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -13,6 +13,9 @@
/*
string synopsis
+#include <compare>
+#include <initializer_list>
+
namespace std
{
@@ -43,11 +46,13 @@ template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT
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;
+ using char_type = charT;
+ using int_type = ...;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
+ using comparison_category = strong_ordering; // Since C++20 only for the specializations
+ // char, wchar_t, char8_t, char16_t, and char32_t.
static void assign(char_type& c1, const char_type& c2) noexcept;
static constexpr bool eq(char_type c1, char_type c2) noexcept;
@@ -104,6 +109,10 @@ public:
const allocator_type& a = allocator_type()); // constexpr since C++20
basic_string(const basic_string& str, size_type pos, size_type n,
const Allocator& a = Allocator()); // constexpr since C++20
+ constexpr basic_string(
+ basic_string&& str, size_type pos, const Allocator& a = Allocator()); // since C++23
+ constexpr basic_string(
+ basic_string&& str, size_type pos, size_type n, const Allocator& a = Allocator()); // since C++23
template<class T>
basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20
template <class T>
@@ -256,8 +265,9 @@ public:
basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20
size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20
- basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr since C++20
-
+ basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23
+ basic_string substr(size_type pos = 0, size_type n = npos) const&; // since C++23
+ constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&; // since C++23
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, constexpr since C++20
@@ -370,60 +380,68 @@ bool operator==(const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
-bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
template<class charT, class traits, class Allocator>
bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
+bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
bool operator< (const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
+bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
bool operator> (const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
+bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
- const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+ const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
template<class charT, class traits, class Allocator>
-bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
+bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
+
+template<class charT, class traits, class Allocator> // since C++20
+constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
+ const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator> // since C++20
+constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
+ const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
void swap(basic_string<charT, traits, Allocator>& lhs,
@@ -526,15 +544,24 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
#include <__format/enable_insertable.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
+#include <__fwd/string.h>
#include <__ios/fpos.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
#include <__iterator/wrap_iter.h>
#include <__memory/allocate_at_least.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/construct_at.h>
+#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__string/char_traits.h>
#include <__string/extern_template_lists.h>
+#include <__type_traits/is_allocator.h>
+#include <__type_traits/noexcept_move_assign_container.h>
#include <__utility/auto_cast.h>
#include <__utility/move.h>
#include <__utility/swap.h>
@@ -544,9 +571,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
#include <cstdio> // EOF
#include <cstdlib>
#include <cstring>
-#include <iosfwd>
#include <limits>
-#include <memory>
#include <stdexcept>
#include <string_view>
#include <type_traits>
@@ -556,16 +581,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
# include <cwchar>
#endif
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-# include <iterator>
-# include <new>
-# include <typeinfo>
-# include <utility>
-# include <vector>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -593,27 +608,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
const basic_string<_CharT, _Traits, _Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
@@ -636,23 +651,10 @@ struct __can_be_converted_to_string_view : public _BoolConstant<
!is_convertible<const _Tp&, const _CharT*>::value
> {};
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
-typedef basic_string<char8_t> u8string;
-#endif
-typedef basic_string<char16_t> u16string;
-typedef basic_string<char32_t> u32string;
-
struct __uninitialized_size_tag {};
template<class _CharT, class _Traits, class _Allocator>
-class
- _LIBCPP_TEMPLATE_VIS
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
- _LIBCPP_PREFERRED_NAME(u8string)
-#endif
- _LIBCPP_PREFERRED_NAME(u16string)
- _LIBCPP_PREFERRED_NAME(u32string)
- basic_string
+class basic_string
{
public:
typedef basic_string __self;
@@ -676,6 +678,11 @@ public:
static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
+ // TODO: Implement iterator bounds checking without requiring the global database.
typedef __wrap_iter<pointer> iterator;
typedef __wrap_iter<const_pointer> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
@@ -787,13 +794,13 @@ private:
// Construct a string with the given allocator and enough storage to hold `__size` characters, but
// don't initialize the characters. The contents of the string, including the null terminator, must be
// initialized separately.
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
: __r_(__default_init_tag(), __a) {
if (__size > max_size())
__throw_length_error();
if (__fits_in_sso(__size)) {
- __zero();
+ __r_.first() = __rep();
__set_short_size(__size);
} else {
auto __capacity = __recommend(__size) + 1;
@@ -806,176 +813,289 @@ private:
std::__debug_db_insert_c(this);
}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {
+ return iterator(this, __p);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {
+ return const_iterator(this, __p);
+ }
+
public:
- _LIBCPP_TEMPLATE_DATA_VIS
- static const size_type npos = -1;
+ _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+ : __r_(__default_init_tag(), __default_init_tag()) {
+ std::__debug_db_insert_c(this);
+ __default_init();
+ }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
- _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
- _NOEXCEPT;
+ _NOEXCEPT
#endif
+ : __r_(__default_init_tag(), __a) {
+ std::__debug_db_insert_c(this);
+ __default_init();
+ }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, const allocator_type& __a);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(basic_string&& __str)
-#if _LIBCPP_STD_VER <= 14
- _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
-#else
- _NOEXCEPT;
-#endif
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)
+# if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+# else
+ _NOEXCEPT
+# endif
+ : __r_(std::move(__str.__r_)) {
+ __str.__default_init();
+ std::__debug_db_insert_c(this);
+ if (__is_long())
+ std::__debug_db_swap(this, &__str);
+ }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(basic_string&& __str, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
+ else {
+ if (__libcpp_is_constant_evaluated())
+ __r_.first() = __rep();
+ __r_.first() = __str.__r_.first();
+ __str.__default_init();
+ }
+ std::__debug_db_insert_c(this);
+ if (__is_long())
+ std::__debug_db_swap(this, &__str);
+ }
#endif // _LIBCPP_CXX03_LANG
- template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- 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));
- std::__debug_db_insert_c(this);
- }
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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));
+ std::__debug_db_insert_c(this);
+ }
- template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(const _CharT* __s, const _Allocator& __a);
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a);
#if _LIBCPP_STD_VER > 20
- basic_string(nullptr_t) = delete;
+ basic_string(nullptr_t) = delete;
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(const _CharT* __s, size_type __n);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(size_type __n, _CharT __c);
-
- template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(size_type __n, _CharT __c, const _Allocator& __a);
-
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(const basic_string& __str, size_type __pos, size_type __n,
- const _Allocator& __a = _Allocator());
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- 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 _LIBCPP_CONSTEXPR_AFTER_CXX17
- 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 _LIBCPP_CONSTEXPR_AFTER_CXX17
- 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 _LIBCPP_CONSTEXPR_AFTER_CXX17
- explicit basic_string(const _Tp& __t, const allocator_type& __a);
-
- template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(_InputIterator __first, _InputIterator __last);
- template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
+ std::__debug_db_insert_c(this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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);
+ std::__debug_db_insert_c(this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c)
+ : __r_(__default_init_tag(), __default_init_tag()) {
+ __init(__n, __c);
+ std::__debug_db_insert_c(this);
+ }
+
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ basic_string(basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())
+ : basic_string(std::move(__str), __pos, npos, __alloc) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ basic_string(basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())
+ : __r_(__default_init_tag(), __alloc) {
+ if (__pos > __str.size())
+ __throw_out_of_range();
+
+ auto __len = std::min<size_type>(__n, __str.size() - __pos);
+ if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) {
+ __r_.first() = __str.__r_.first();
+ __str.__default_init();
+
+ _Traits::move(data(), data() + __pos, __len);
+ __set_size(__len);
+ _Traits::assign(data()[__len], value_type());
+ } else {
+ // Perform a copy because the allocators are not compatible.
+ __init(__str.data() + __pos, __len);
+ }
+
+ std::__debug_db_insert_c(this);
+ if (__is_long())
+ std::__debug_db_swap(this, &__str);
+ }
+#endif
+
+ template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a);
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator());
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator())
+ : __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);
+ std::__debug_db_insert_c(this);
+ }
+
+ 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 _LIBCPP_CONSTEXPR_SINCE_CXX20
+ 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 _LIBCPP_CONSTEXPR_SINCE_CXX20 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 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
+ const _Tp& __t, const allocator_type& __a);
+
+ template <class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last)
+ : __r_(__default_init_tag(), __default_init_tag()) {
+ __init(__first, __last);
+ std::__debug_db_insert_c(this);
+ }
+
+ template <class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a) {
+ __init(__first, __last);
+ std::__debug_db_insert_c(this);
+ }
+
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(initializer_list<_CharT> __il);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il)
+ : __r_(__default_init_tag(), __default_init_tag()) {
+ __init(__il.begin(), __il.end());
+ std::__debug_db_insert_c(this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)
+ : __r_(__default_init_tag(), __a) {
+ __init(__il.begin(), __il.end());
+ std::__debug_db_insert_c(this);
+ }
#endif // _LIBCPP_CXX03_LANG
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string();
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string();
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const basic_string& __str);
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_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {
__self_view __sv = __t;
return assign(__sv);
}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& operator=(basic_string&& __str)
- _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& 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;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& operator=(const value_type* __s) {return assign(__s);}
#if _LIBCPP_STD_VER > 20
basic_string& operator=(nullptr_t) = delete;
#endif
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator begin() _NOEXCEPT
- {return iterator(this, __get_pointer());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ {return __make_iterator(__get_pointer());}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator begin() const _NOEXCEPT
- {return const_iterator(this, __get_pointer());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ {return __make_const_iterator(__get_pointer());}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator end() _NOEXCEPT
- {return iterator(this, __get_pointer() + size());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ {return __make_iterator(__get_pointer() + size());}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator end() const _NOEXCEPT
- {return const_iterator(this, __get_pointer() + size());}
+ {return __make_const_iterator(__get_pointer() + size());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator cbegin() const _NOEXCEPT
{return begin();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator cend() const _NOEXCEPT
{return end();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT
{return __is_long() ? __get_long_size() : __get_short_size();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT {return size();}
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {
+ size_type __m = __alloc_traits::max_size(__alloc());
+ if (__m <= std::numeric_limits<size_type>::max() / 2) {
+ return __m - __alignment;
+ } else {
+ bool __uses_lsb = __endian_factor == 2;
+ return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {
return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;
}
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n, value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__n, value_type()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity);
#if _LIBCPP_STD_VER > 20
template <class _Op>
@@ -986,28 +1106,34 @@ public:
}
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool empty() const _NOEXCEPT {return size() == 0;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- const_reference operator[](size_type __pos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT {
+ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+ return *(data() + __pos);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __pos) _NOEXCEPT {
+ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+ return *(__get_pointer() + __pos);
+ }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
- _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const basic_string& __str) {
return append(__str);
}
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -1018,35 +1144,36 @@ public:
__self_view __sv = __t; return append(__sv);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) {
return append(__s);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(value_type __c) {
push_back(__c);
return *this;
}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& append(const basic_string& __str);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {
+ return append(__str.data(), __str.size());
+ }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -1054,11 +1181,11 @@ public:
basic_string&
>
append(const _Tp& __t, size_type __pos, size_type __n=npos);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __append_default_init(size_type __n);
template<class _InputIterator>
@@ -1068,7 +1195,7 @@ public:
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
basic_string&
>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
append(_InputIterator __first, _InputIterator __last) {
const basic_string __temp(__first, __last, __alloc());
append(__temp.data(), __temp.size());
@@ -1081,40 +1208,56 @@ public:
__is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_string&
>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
append(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back();
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT {
+ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+ return *__get_pointer();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const _NOEXCEPT {
+ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+ return *data();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() _NOEXCEPT {
+ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+ return *(__get_pointer() + size() - 1);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const _NOEXCEPT {
+ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+ return *(data() + size() - 1);
+ }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& assign(const basic_string& __str) { return *this = __str; }
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& assign(basic_string&& __str)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
{*this = std::move(__str); return *this;}
#endif
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -1122,11 +1265,11 @@ public:
basic_string&
>
assign(const _Tp & __t, size_type __pos, size_type __n=npos);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -1134,7 +1277,7 @@ public:
>
assign(_InputIterator __first, _InputIterator __last);
template<class _ForwardIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1142,15 +1285,17 @@ public:
>
assign(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& insert(size_type __pos1, const basic_string& __str);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ insert(size_type __pos1, const basic_string& __str) {
+ return insert(__pos1, __str.data(), __str.size());
+ }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1160,23 +1305,31 @@ public:
{ __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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);
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- iterator insert(const_iterator __pos, size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
+ 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;
+ }
+
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -1184,7 +1337,7 @@ public:
>
insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
template<class _ForwardIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1192,47 +1345,53 @@ public:
>
insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator insert(const_iterator __pos, initializer_list<value_type> __il)
{return insert(__pos, __il.begin(), __il.end());}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator erase(const_iterator __pos);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ replace(size_type __pos1, size_type __n1, const basic_string& __str) {
+ return replace(__pos1, __n1, __str.data(), __str.size());
+ }
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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);
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ 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 _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1240,14 +1399,23 @@ public:
>
replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ 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);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ 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);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ 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);
+ }
+
template<class _InputIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_input_iterator<_InputIterator>::value,
@@ -1255,16 +1423,31 @@ public:
>
replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
- _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- basic_string substr(size_type __pos = 0, size_type __n = npos) const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+#if _LIBCPP_STD_VER <= 20
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ basic_string substr(size_type __pos = 0, size_type __n = npos) const {
+ return basic_string(*this, __pos, __n);
+ }
+#else
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ basic_string substr(size_type __pos = 0, size_type __n = npos) const& {
+ return basic_string(*this, __pos, __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ basic_string substr(size_type __pos = 0, size_type __n = npos) && {
+ return basic_string(std::move(*this), __pos, __n);
+ }
+#endif
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
@@ -1273,129 +1456,129 @@ public:
__is_nothrow_swappable<allocator_type>::value);
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const value_type* c_str() const _NOEXCEPT {return data();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}
#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
int compare(const basic_string& __str) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1404,7 +1587,7 @@ public:
compare(const _Tp &__t) const _NOEXCEPT;
template <class _Tp>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -1412,23 +1595,23 @@ public:
>
compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
__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;
- _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT;
- _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
#if _LIBCPP_STD_VER > 17
@@ -1471,9 +1654,9 @@ public:
{ return __self_view(data(), size()).contains(__s); }
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@@ -1486,20 +1669,20 @@ public:
private:
template<class _Alloc>
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool __is_long() const _NOEXCEPT {
if (__libcpp_is_constant_evaluated())
return true;
return __r_.first().__s.__is_long_;
}
- static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) {
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) {
#if _LIBCPP_STD_VER > 17
if (__libcpp_is_constant_evaluated()) {
for (size_type __i = 0; __i != __n; ++__i)
@@ -1511,8 +1694,8 @@ private:
#endif // _LIBCPP_STD_VER > 17
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() {
- __zero();
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() {
+ __r_.first() = __rep();
if (__libcpp_is_constant_evaluated()) {
size_type __sz = __recommend(0) + 1;
pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);
@@ -1523,7 +1706,7 @@ private:
}
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __deallocate_constexpr() {
if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)
__alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());
}
@@ -1534,7 +1717,7 @@ private:
}
template <class _ForwardIterator>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
size_type __sz = size();
size_type __cap = capacity();
@@ -1560,76 +1743,71 @@ private:
return begin() + __ip;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __set_short_size(size_type __s) _NOEXCEPT {
_LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
__r_.first().__s.__size_ = __s;
__r_.first().__s.__is_long_ = false;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type __get_short_size() const _NOEXCEPT {
_LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");
return __r_.first().__s.__size_;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __set_long_size(size_type __s) _NOEXCEPT
{__r_.first().__l.__size_ = __s;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type __get_long_size() const _NOEXCEPT
{return __r_.first().__l.__size_;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __set_size(size_type __s) _NOEXCEPT
{if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __set_long_cap(size_type __s) _NOEXCEPT {
__r_.first().__l.__cap_ = __s / __endian_factor;
__r_.first().__l.__is_long_ = true;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type __get_long_cap() const _NOEXCEPT {
return __r_.first().__l.__cap_ * __endian_factor;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __set_long_pointer(pointer __p) _NOEXCEPT
{__r_.first().__l.__data_ = __p;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
pointer __get_long_pointer() _NOEXCEPT
{return __r_.first().__l.__data_;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_pointer __get_long_pointer() const _NOEXCEPT
{return __r_.first().__l.__data_;}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
pointer __get_short_pointer() _NOEXCEPT
{return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_pointer __get_short_pointer() const _NOEXCEPT
{return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
pointer __get_pointer() _NOEXCEPT
{return __is_long() ? __get_long_pointer() : __get_short_pointer();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_pointer __get_pointer() const _NOEXCEPT
{return __is_long() ? __get_long_pointer() : __get_short_pointer();}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- void __zero() _NOEXCEPT {
- __r_.first() = __rep();
- }
-
template <size_type __a> static
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type __align_it(size_type __s) _NOEXCEPT
{return (__s + (__a-1)) & ~(__a-1);}
enum {__alignment = 16};
- static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type __recommend(size_type __s) _NOEXCEPT
{
if (__s < __min_cap) {
@@ -1644,11 +1822,11 @@ private:
return __guess;
}
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void __init(const value_type* __s, size_type __sz, size_type __reserve);
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void __init(const value_type* __s, size_type __sz);
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void __init(size_type __n, value_type __c);
// Slow path for the (inlined) copy constructor for 'long' strings.
@@ -1659,10 +1837,10 @@ private:
// 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.
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
template <class _InputIterator>
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value
@@ -1670,17 +1848,17 @@ private:
__init(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
- inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value
>
__init(_ForwardIterator __first, _ForwardIterator __last);
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
- _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
@@ -1689,21 +1867,22 @@ private:
// have proof that the input does not alias the current instance.
// For example, operator=(basic_string) performs a 'self' check.
template <bool __is_short>
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
- void __erase_to_end(size_type __pos);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {
+ __null_terminate_at(std::__to_address(__get_pointer()), __pos);
+ }
// __erase_external_with_move is invoked for erase() invocations where
// `n ~= npos`, likely requiring memory moves on the string data.
- _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_external_with_move(size_type __pos, size_type __n);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __copy_assign_alloc(const basic_string& __str)
{__copy_assign_alloc(__str, integral_constant<bool,
__alloc_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __copy_assign_alloc(const basic_string& __str, true_type)
{
if (__alloc() == __str.__alloc())
@@ -1720,7 +1899,7 @@ private:
allocator_type __a = __str.__alloc();
auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
__begin_lifetime(__allocation.ptr, __allocation.count);
- __clear_and_shrink();
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
__alloc() = std::move(__a);
__set_long_pointer(__allocation.ptr);
__set_long_cap(__allocation.count);
@@ -1729,15 +1908,15 @@ private:
}
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
{}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign(basic_string& __str, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign(basic_string& __str, true_type)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
@@ -1746,7 +1925,7 @@ private:
#endif
#endif
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__move_assign_alloc(basic_string& __str)
_NOEXCEPT_(
@@ -1755,20 +1934,20 @@ private:
{__move_assign_alloc(__str, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign_alloc(basic_string& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = std::move(__c.__alloc());
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign_alloc(basic_string&, false_type)
_NOEXCEPT
{}
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s);
- _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 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) {
@@ -1780,7 +1959,7 @@ private:
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
__set_size(__newsz);
__invalidate_iterators_past(__newsz);
@@ -1788,10 +1967,10 @@ private:
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __invalidate_iterators_past(size_type);
template<class _Tp>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool __addr_in_range(_Tp&& __t) const {
// assume that the ranges overlap, because we can't check during constant evaluation
if (__libcpp_is_constant_evaluated())
@@ -1810,11 +1989,11 @@ private:
std::__throw_out_of_range("basic_string");
}
- friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&);
- friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&);
- friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&);
- friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*);
- friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type);
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const value_type*, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(value_type, const basic_string&);
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const value_type*);
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, value_type);
};
// These declarations must appear before any functions are implicitly used
@@ -1863,7 +2042,7 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
#endif
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
{
@@ -1893,37 +2072,13 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __r_(__default_init_tag(), __default_init_tag())
-{
- std::__debug_db_insert_c(this);
- __default_init();
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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)
-{
- std::__debug_db_insert_c(this);
- __default_init();
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
size_type __sz,
size_type __reserve)
{
if (__libcpp_is_constant_evaluated())
- __zero();
+ __r_.first() = __rep();
if (__reserve > max_size())
__throw_length_error();
pointer __p;
@@ -1946,12 +2101,12 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
{
if (__libcpp_is_constant_evaluated())
- __zero();
+ __r_.first() = __rep();
if (__sz > max_size())
__throw_length_error();
pointer __p;
@@ -1975,7 +2130,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
template <class _CharT, class _Traits, class _Allocator>
template <class>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
@@ -1985,32 +2140,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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);
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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);
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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;
+ __r_.first() = __str.__r_.first();
else
__init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
@@ -2018,13 +2153,13 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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;
+ __r_.first() = __str.__r_.first();
else
__init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
__str.__get_long_size());
@@ -2032,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
const value_type* __s, size_type __sz) {
if (__libcpp_is_constant_evaluated())
- __zero();
+ __r_.first() = __rep();
+
pointer __p;
if (__fits_in_sso(__sz)) {
__p = __get_short_pointer();
@@ -2054,55 +2190,14 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
traits_type::copy(std::__to_address(__p), __s, __sz + 1);
}
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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_(std::move(__str.__r_))
-{
- __str.__default_init();
- std::__debug_db_insert_c(this);
- if (__is_long())
- std::__debug_db_swap(this, &__str);
-}
-
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
- else
- {
- if (__libcpp_is_constant_evaluated()) {
- __zero();
- __r_.first().__l = __str.__r_.first().__l;
- } else {
- __r_.first().__r = __str.__r_.first().__r;
- }
- __str.__default_init();
- }
- std::__debug_db_insert_c(this);
- if (__is_long())
- std::__debug_db_swap(this, &__str);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
{
if (__libcpp_is_constant_evaluated())
- __zero();
+ __r_.first() = __rep();
+
if (__n > max_size())
__throw_length_error();
pointer __p;
@@ -2125,17 +2220,8 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
- : __r_(__default_init_tag(), __default_init_tag())
-{
- __init(__n, __c);
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
template <class>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
@@ -2144,7 +2230,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
size_type __pos, size_type __n,
const _Allocator& __a)
@@ -2158,21 +2244,8 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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);
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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)
@@ -2185,7 +2258,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
: __r_(__default_init_tag(), __default_init_tag())
{
@@ -2196,7 +2269,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
: __r_(__default_init_tag(), __a)
{
@@ -2207,7 +2280,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _
template <class _CharT, class _Traits, class _Allocator>
template <class _InputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value
@@ -2234,7 +2307,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
template <class _CharT, class _Traits, class _Allocator>
template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value
@@ -2242,7 +2315,7 @@ __enable_if_t
basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
{
if (__libcpp_is_constant_evaluated())
- __zero();
+ __r_.first() = __rep();
size_type __sz = static_cast<size_type>(std::distance(__first, __last));
if (__sz > max_size())
__throw_length_error();
@@ -2281,52 +2354,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
}
template <class _CharT, class _Traits, class _Allocator>
-template<class _InputIterator, class>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
- : __r_(__default_init_tag(), __default_init_tag())
-{
- __init(__first, __last);
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-template<class _InputIterator, class>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
- const allocator_type& __a)
- : __r_(__default_init_tag(), __a)
-{
- __init(__first, __last);
- std::__debug_db_insert_c(this);
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string(
- initializer_list<_CharT> __il)
- : __r_(__default_init_tag(), __default_init_tag())
-{
- __init(__il.begin(), __il.end());
- std::__debug_db_insert_c(this);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-basic_string<_CharT, _Traits, _Allocator>::basic_string(
- initializer_list<_CharT> __il, const _Allocator& __a)
- : __r_(__default_init_tag(), __a)
-{
- __init(__il.begin(), __il.end());
- std::__debug_db_insert_c(this);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>::~basic_string()
{
std::__debug_db_erase_c(this);
@@ -2335,7 +2363,7 @@ basic_string<_CharT, _Traits, _Allocator>::~basic_string()
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
@@ -2372,7 +2400,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
template <class _CharT, class _Traits, class _Allocator>
void
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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)
{
@@ -2405,7 +2433,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
template <class _CharT, class _Traits, class _Allocator>
template <bool __is_short>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
const value_type* __s, size_type __n) {
@@ -2424,7 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_external(
const value_type* __s, size_type __n) {
@@ -2441,7 +2469,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
{
@@ -2452,7 +2480,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
{
@@ -2468,7 +2496,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
{
@@ -2490,7 +2518,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
{
@@ -2498,7 +2526,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
__copy_assign_alloc(__str);
if (!__is_long()) {
if (!__str.__is_long()) {
- __r_.first().__r = __str.__r_.first().__r;
+ __r_.first() = __str.__r_.first();
} else {
return __assign_no_alias<true>(__str.data(), __str.size());
}
@@ -2512,7 +2540,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -2524,7 +2552,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
#if _LIBCPP_STD_VER > 14
@@ -2553,22 +2581,11 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
}
}
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -2583,7 +2600,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2619,7 +2636,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
{
@@ -2631,7 +2648,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -2649,14 +2666,14 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
{
@@ -2670,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
// append
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
{
@@ -2694,7 +2711,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
{
@@ -2714,7 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
{
if (__n)
@@ -2731,7 +2748,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
{
@@ -2770,7 +2787,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2805,15 +2822,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
{
@@ -2825,7 +2834,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -2841,7 +2850,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
{
@@ -2852,7 +2861,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
// insert
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
{
@@ -2892,7 +2901,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
{
@@ -2925,7 +2934,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_exactly_cpp17_input_iterator<_InputIterator>::value,
@@ -2942,7 +2951,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2970,15 +2979,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
size_type __pos2, size_type __n)
@@ -2991,7 +2992,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -3008,7 +3009,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
{
@@ -3017,7 +3018,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
{
@@ -3047,23 +3048,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
return begin() + static_cast<difference_type>(__ip);
}
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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
@@ -3117,7 +3105,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
{
@@ -3148,7 +3136,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__is_cpp17_input_iterator<_InputIterator>::value,
@@ -3162,15 +3150,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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)
@@ -3183,7 +3163,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
@@ -3200,7 +3180,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
{
@@ -3208,45 +3188,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
return replace(__pos, __n1, __s, traits_type::length(__s));
}
-template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
size_type __pos, size_type __n)
@@ -3264,7 +3211,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
size_type __n) {
@@ -3279,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
{
@@ -3295,7 +3242,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -3311,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::pop_back()
{
@@ -3320,7 +3267,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
{
@@ -3338,15 +3285,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
-{
- __null_terminate_at(std::__to_address(__get_pointer()), __pos);
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
{
@@ -3358,7 +3297,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
{
size_type __sz = size();
@@ -3369,21 +3308,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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());
- if (__m <= std::numeric_limits<size_type>::max() / 2) {
- return __m - __alignment;
- } else {
- bool __uses_lsb = __endian_factor == 2;
- return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
- }
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
{
@@ -3404,7 +3329,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -3415,7 +3340,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
{
@@ -3479,25 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
{
@@ -3507,7 +3414,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::reference
basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
{
@@ -3517,43 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
-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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
{
@@ -3566,15 +3437,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
-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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
@@ -3610,30 +3473,30 @@ struct _LIBCPP_HIDDEN __traits_eq
};
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3643,58 +3506,58 @@ 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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __sv.data(), __pos, __sv.size());
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
// rfind
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3704,58 +3567,58 @@ 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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __sv.data(), __pos, __sv.size());
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
// find_first_of
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3765,23 +3628,23 @@ 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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3792,30 +3655,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
// find_last_of
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3825,23 +3688,23 @@ 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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
size_type __pos) const _NOEXCEPT
@@ -3852,30 +3715,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
// find_first_not_of
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3885,58 +3748,58 @@ 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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3946,28 +3809,28 @@ 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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__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 _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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>
+ return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
@@ -3975,7 +3838,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -3998,7 +3861,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
{
@@ -4006,7 +3869,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -4031,7 +3894,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
@@ -4046,7 +3909,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -4057,7 +3920,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t
<
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
@@ -4075,7 +3938,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -4087,7 +3950,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
{
@@ -4096,7 +3959,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const
}
template <class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_CONSTEXPR_SINCE_CXX20
int
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
@@ -4109,7 +3972,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
// __invariants
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
basic_string<_CharT, _Traits, _Allocator>::__invariants() const
{
@@ -4127,7 +3990,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
// __clear_and_shrink
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
void
basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
{
@@ -4135,28 +3998,30 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
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());
+ __default_init();
}
}
// operator==
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
{
+#if _LIBCPP_STD_VER > 17
+ return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
+#else
size_t __lhs_sz = __lhs.size();
return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
__rhs.data(),
__lhs_sz) == 0;
+#endif
}
template<class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
@@ -4174,8 +4039,9 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
return true;
}
+#if _LIBCPP_STD_VER <= 17
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator==(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4186,22 +4052,44 @@ operator==(const _CharT* __lhs,
if (__lhs_len != __rhs.size()) return false;
return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
}
+#endif // _LIBCPP_STD_VER <= 17
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
bool
operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
{
+#if _LIBCPP_STD_VER > 17
+ return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
+#else
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;
+#endif
}
+#if _LIBCPP_STD_VER > 17
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
+ const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+ const basic_string<_CharT, _Traits, _Allocator>& __rhs) noexcept {
+ return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
+ return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);
+}
+
+#else // _LIBCPP_STD_VER > 17
+
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4210,7 +4098,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4219,7 +4107,7 @@ operator!=(const _CharT* __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4230,7 +4118,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
// operator<
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4239,7 +4127,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4248,7 +4136,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator< (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4259,7 +4147,7 @@ operator< (const _CharT* __lhs,
// operator>
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4268,7 +4156,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4277,7 +4165,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator> (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4288,7 +4176,7 @@ operator> (const _CharT* __lhs,
// operator<=
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4297,7 +4185,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4306,7 +4194,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4317,7 +4205,7 @@ operator<=(const _CharT* __lhs,
// operator>=
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
@@ -4326,7 +4214,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs) _NOEXCEPT
@@ -4335,18 +4223,19 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
{
return !(__lhs < __rhs);
}
+#endif // _LIBCPP_STD_VER > 17
// operator +
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
@@ -4365,7 +4254,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
}
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
{
@@ -4383,7 +4272,7 @@ operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& _
}
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
{
@@ -4400,7 +4289,7 @@ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
{
@@ -4418,7 +4307,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT*
}
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
{
@@ -4437,7 +4326,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
#ifndef _LIBCPP_CXX03_LANG
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
@@ -4445,7 +4334,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
{
@@ -4453,7 +4342,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
{
@@ -4461,7 +4350,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
{
@@ -4469,7 +4358,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
{
@@ -4478,7 +4367,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
{
@@ -4486,7 +4375,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs
}
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<_CharT, _Traits, _Allocator>
operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
{
@@ -4499,7 +4388,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
// swap
template<class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
basic_string<_CharT, _Traits, _Allocator>& __rhs)
@@ -4556,27 +4445,44 @@ 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>
+struct __string_hash : 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()); }
+ { return std::__do_string_hash(__val.data(), __val.data() + __val.size()); }
};
+template <class _Allocator>
+struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <class _Allocator>
+struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};
+#endif
+
+template <class _Allocator>
+struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {};
+
+template <class _Allocator>
+struct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _Allocator>
+struct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {};
+#endif
+
template<class _CharT, class _Traits, class _Allocator>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI 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>&
+_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
@@ -4662,14 +4568,14 @@ inline namespace literals
{
inline namespace string_literals
{
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
{
return basic_string<wchar_t> (__str, __len);
@@ -4678,19 +4584,19 @@ inline namespace literals
#ifndef _LIBCPP_HAS_NO_CHAR8_T
inline _LIBCPP_HIDE_FROM_ABI constexpr
- basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
+ basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len)
{
return basic_string<char8_t> (__str, __len);
}
#endif
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
{
return basic_string<char16_t> (__str, __len);
}
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
{
return basic_string<char32_t> (__str, __len);
@@ -4713,4 +4619,15 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <concepts>
+# include <functional>
+# include <iterator>
+# include <new>
+# include <typeinfo>
+# include <utility>
+# include <vector>
+#endif
+
#endif // _LIBCPP_STRING
diff --git a/libcxx/include/string.h b/libcxx/include/string.h
index 082c632a29bc..3ec877bad310 100644
--- a/libcxx/include/string.h
+++ b/libcxx/include/string.h
@@ -57,7 +57,9 @@ size_t strlen(const char* s);
# pragma GCC system_header
#endif
-#include_next <string.h>
+#if __has_include_next(<string.h>)
+# 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
@@ -69,41 +71,41 @@ size_t strlen(const char* s);
#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);}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {
+ return __builtin_strchr(__s, __c);
+}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) {
+ return __builtin_strchr(__s, __c);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) {
+ return __builtin_strpbrk(__s1, __s2);
+}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) {
+ return __builtin_strpbrk(__s1, __s2);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) {
+ return __builtin_strrchr(__s, __c);
+}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) {
+ return __builtin_strrchr(__s, __c);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
+ return __builtin_memchr(__s, __c, __n);
+}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
+ return __builtin_memchr(__s, __c, __n);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) {
+ return __builtin_strstr(__s1, __s2);
+}
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {
+ return __builtin_strstr(__s1, __s2);
}
+} // extern "C++"
#endif
#endif // _LIBCPP_STRING_H
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index a84ed5019614..ea98e38de871 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -14,6 +14,8 @@
string_view synopsis
+#include <compare>
+
namespace std {
// 7.2, Class template basic_string_view
@@ -30,21 +32,25 @@ namespace std {
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>
+ template<class charT, class traits> // Removed in C++20
constexpr bool operator!=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
- template<class charT, class traits>
+ template<class charT, class traits> // Removed in C++20
constexpr bool operator< (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
- template<class charT, class traits>
+ template<class charT, class traits> // Removed in C++20
constexpr bool operator> (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
- template<class charT, class traits>
+ template<class charT, class traits> // Removed in C++20
constexpr bool operator<=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
- template<class charT, class traits>
+ template<class charT, class traits> // Removed in C++20
constexpr bool operator>=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
+ template<class charT, class traits> // Since C++20
+ constexpr see below 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
@@ -185,11 +191,11 @@ namespace std {
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;
+ 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
@@ -218,12 +224,6 @@ namespace std {
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -256,29 +256,21 @@ inline size_t __char_traits_length_checked(const typename _Traits::char_type* __
}
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 {
+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 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;
+ using traits_type = _Traits;
+ using value_type = _CharT;
+ using pointer = _CharT*;
+ using const_pointer = const _CharT*;
+ using reference = _CharT&;
+ using const_reference = const _CharT&;
+ using const_iterator = const_pointer; // See [string.view.iterators]
+ using iterator = const_iterator;
+ using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
+ using reverse_iterator = const_reverse_iterator;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
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");
@@ -289,7 +281,7 @@ public:
// [string.view.cons], construct/copy
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
+ basic_string_view() _NOEXCEPT : __data_(nullptr), __size_(0) {}
_LIBCPP_INLINE_VISIBILITY
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
@@ -299,7 +291,7 @@ public:
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
- : __data(__s), __size(__len)
+ : __data_(__s), __size_(__len)
{
#if _LIBCPP_STD_VER > 11
_LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
@@ -310,13 +302,13 @@ public:
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)
+ : __data_(_VSTD::to_address(__begin)), __size_(__end - __begin)
{
_LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
}
#endif // _LIBCPP_STD_VER > 17
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 20
template <class _Range>
requires (
!is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
@@ -331,13 +323,13 @@ public:
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_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+ constexpr explicit _LIBCPP_HIDE_FROM_ABI
+ basic_string_view(_Range&& __r) : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}
+#endif // _LIBCPP_STD_VER > 20
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s)
- : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
+ : __data_(__s), __size_(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
#if _LIBCPP_STD_VER > 20
basic_string_view(nullptr_t) = delete;
@@ -351,94 +343,94 @@ public:
const_iterator end() const _NOEXCEPT { return cend(); }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- const_iterator cbegin() const _NOEXCEPT { return __data; }
+ const_iterator cbegin() const _NOEXCEPT { return __data_; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- const_iterator cend() const _NOEXCEPT { return __data + __size; }
+ const_iterator cend() const _NOEXCEPT { return __data_ + __size_; }
- _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
- _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX17 _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; }
+ size_type size() const _NOEXCEPT { return __size_; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- size_type length() const _NOEXCEPT { return __size; }
+ 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; }
+ 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];
+ 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];
+ ? (__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];
+ 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];
+ 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; }
+ const_pointer data() const _NOEXCEPT { return __data_; }
// [string.view.modifiers], modifiers:
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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;
+ __data_ += __n;
+ __size_ -= __n;
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
void remove_suffix(size_type __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
- __size -= __n;
+ __size_ -= __n;
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
void swap(basic_string_view& __other) _NOEXCEPT
{
- const value_type *__p = __data;
- __data = __other.__data;
- __other.__data = __p;
+ const value_type *__p = __data_;
+ __data_ = __other.__data_;
+ __other.__data_ = __p;
- size_type __sz = __size;
- __size = __other.__size;
- __other.__size = __sz;
+ size_type __sz = __size_;
+ __size_ = __other.__size_;
+ __other.__size_ = __sz;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if (__pos > size())
@@ -456,229 +448,229 @@ public:
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT
{
- size_type __rlen = _VSTD::min( size(), __sv.size());
+ 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 );
+ 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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
int compare(const _CharT* __s) const _NOEXCEPT
{
return compare(basic_string_view(__s));
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
{
- return __str_find<value_type, size_type, traits_type, npos>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
{
- return __str_rfind<value_type, size_type, traits_type, npos>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _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>
+ return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
@@ -723,9 +715,10 @@ public:
#endif
private:
- const value_type* __data;
- size_type __size;
+ const value_type* __data_;
+ size_type __size_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
#if _LIBCPP_STD_VER > 17
template <class _CharT, class _Traits>
@@ -743,69 +736,105 @@ template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
#endif // _LIBCPP_STD_VER > 17
-#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 20
template <ranges::contiguous_range _Range>
basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
-#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif
// [string.view.comparison]
// operator ==
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _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;
+ 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
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
{
- if ( __lhs.size() != __rhs.size()) return false;
+ if (__lhs.size() != __rhs.size()) return false;
return __lhs.compare(__rhs) == 0;
}
+#if _LIBCPP_STD_VER < 20
+// This overload is automatically generated in C++20.
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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
- if ( __lhs.size() != __rhs.size()) return false;
+ if (__lhs.size() != __rhs.size()) return false;
return __lhs.compare(__rhs) == 0;
}
+#endif // _LIBCPP_STD_VER > 17
+// operator <=>
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
+ if constexpr (requires { typename _Traits::comparison_category; }) {
+ // [string.view]/4
+ static_assert(
+ __comparison_category<typename _Traits::comparison_category>,
+ "return type is not a comparison category type");
+ return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
+ } else {
+ return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
+ }
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
+ basic_string_view<_CharT, _Traits> __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
+ if constexpr (requires { typename _Traits::comparison_category; }) {
+ // [string.view]/4
+ static_assert(
+ __comparison_category<typename _Traits::comparison_category>,
+ "return type is not a comparison category type");
+ return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
+ } else {
+ return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
+ }
+}
+
+#else // _LIBCPP_STD_VER > 17
// operator !=
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
- if ( __lhs.size() != __rhs.size())
+ 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
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
{
- if ( __lhs.size() != __rhs.size())
+ 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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
- if ( __lhs.size() != __rhs.size())
+ if (__lhs.size() != __rhs.size())
return true;
return __lhs.compare(__rhs) != 0;
}
@@ -813,23 +842,23 @@ bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type
// operator <
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator<(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) < 0;
@@ -838,23 +867,23 @@ bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type _
// operator >
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator>(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) > 0;
@@ -863,23 +892,23 @@ bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type _
// operator <=
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _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
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) <= 0;
@@ -888,7 +917,7 @@ bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type
// operator >=
template<class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) >= 0;
@@ -896,38 +925,57 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha
template<class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
- typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+ __type_identity_t<basic_string_view<_CharT, _Traits> > __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,
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
+bool operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) >= 0;
}
+#endif // _LIBCPP_STD_VER > 17
template<class _CharT, class _Traits>
-basic_ostream<_CharT, _Traits>&
+_LIBCPP_HIDE_FROM_ABI 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>
+struct __string_view_hash : 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());
+ return std::__do_string_hash(__val.data(), __val.data() + __val.size());
}
};
+template <>
+struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <>
+struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
+#endif
+
+template <>
+struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};
+
+template <>
+struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};
+#endif
+
#if _LIBCPP_STD_VER > 11
inline namespace literals
{
@@ -973,4 +1021,11 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <concepts>
+# include <functional>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_STRING_VIEW
diff --git a/libcxx/include/strstream b/libcxx/include/strstream
index 72386bb9567f..9382473f68f5 100644
--- a/libcxx/include/strstream
+++ b/libcxx/include/strstream
@@ -167,7 +167,7 @@ public:
strstreambuf& operator=(strstreambuf&& __rhs);
#endif // _LIBCPP_CXX03_LANG
- virtual ~strstreambuf();
+ ~strstreambuf() override;
void swap(strstreambuf& __rhs);
@@ -176,13 +176,13 @@ public:
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);
+ int_type overflow (int_type __c = EOF) override;
+ int_type pbackfail(int_type __c = EOF) override;
+ int_type underflow() override;
+ pos_type seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __which = ios_base::in | ios_base::out) override;
+ pos_type seekpos(pos_type __sp,
+ ios_base::openmode __which = ios_base::in | ios_base::out) override;
private:
typedef unsigned __mode_type;
@@ -272,7 +272,7 @@ public:
}
#endif // _LIBCPP_CXX03_LANG
- virtual ~istrstream();
+ ~istrstream() override;
_LIBCPP_INLINE_VISIBILITY
void swap(istrstream& __rhs)
@@ -321,7 +321,7 @@ public:
}
#endif // _LIBCPP_CXX03_LANG
- virtual ~ostrstream();
+ ~ostrstream() override;
_LIBCPP_INLINE_VISIBILITY
void swap(ostrstream& __rhs)
@@ -381,7 +381,7 @@ public:
}
#endif // _LIBCPP_CXX03_LANG
- virtual ~strstream();
+ ~strstream() override;
_LIBCPP_INLINE_VISIBILITY
void swap(strstream& __rhs)
diff --git a/libcxx/include/system_error b/libcxx/include/system_error
index 3b705aa81ebc..98919927bc04 100644
--- a/libcxx/include/system_error
+++ b/libcxx/include/system_error
@@ -32,8 +32,9 @@ public:
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;
+ bool operator!=(const error_category& rhs) const noexcept; // removed in C++20
+ bool operator<(const error_category& rhs) const noexcept; // removed in C++20
+ strong_ordering operator<=>(const error_category& rhs) const noexcept; // C++20
};
const error_category& generic_category() noexcept;
@@ -75,7 +76,6 @@ public:
};
// 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);
@@ -102,8 +102,6 @@ public:
explicit operator bool() const noexcept;
};
-bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
-
class system_error
: public runtime_error
{
@@ -128,12 +126,16 @@ 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_code& rhs) noexcept; // removed in C++20
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;
+bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20
+bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; // removed in C++20
+bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20
+bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20
+bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20
+bool operator<(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20
+strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept; // C++20
+strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept; // C++20
template <> struct hash<std::error_code>;
template <> struct hash<std::error_condition>;
@@ -147,12 +149,15 @@ template <> struct hash<std::error_condition>;
#include <__errc>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
+#include <__memory/addressof.h>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <version>
// standard-mandated includes
+
+// [system.error.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -209,7 +214,7 @@ public:
error_category() noexcept;
#else
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default;
#endif
error_category(const error_category&) = delete;
error_category& operator=(const error_category&) = delete;
@@ -223,12 +228,21 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
+#if _LIBCPP_STD_VER > 17
+
+ _LIBCPP_HIDE_FROM_ABI
+ strong_ordering operator<=>(const error_category& __rhs) const noexcept {return compare_three_way()(this, std::addressof(__rhs));}
+
+#else // _LIBCPP_STD_VER > 17
+
_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;}
+#endif // _LIBCPP_STD_VER > 17
+
friend class _LIBCPP_HIDDEN __do_message;
};
@@ -236,12 +250,19 @@ class _LIBCPP_HIDDEN __do_message
: public error_category
{
public:
- virtual string message(int __ev) const;
+ string message(int __ev) const override;
};
_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
+namespace __adl_only {
+ // Those cause ADL to trigger but they are not viable candidates,
+ // so they are never actually selected.
+ void make_error_condition() = delete;
+ void make_error_code() = delete;
+} // namespace __adl_only
+
class _LIBCPP_TYPE_VIS error_condition
{
int __val_;
@@ -259,7 +280,10 @@ public:
error_condition(_Ep __e,
typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
) _NOEXCEPT
- {*this = make_error_condition(__e);}
+ {
+ using __adl_only::make_error_condition;
+ *this = make_error_condition(__e);
+ }
_LIBCPP_INLINE_VISIBILITY
void assign(int __val, const error_category& __cat) _NOEXCEPT
@@ -276,7 +300,11 @@ public:
error_condition&
>::type
operator=(_Ep __e) _NOEXCEPT
- {*this = make_error_condition(__e); return *this;}
+ {
+ using __adl_only::make_error_condition;
+ *this = make_error_condition(__e);
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
@@ -303,14 +331,6 @@ 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
@@ -330,7 +350,10 @@ public:
error_code(_Ep __e,
typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
) _NOEXCEPT
- {*this = make_error_code(__e);}
+ {
+ using __adl_only::make_error_code;
+ *this = make_error_code(__e);
+ }
_LIBCPP_INLINE_VISIBILITY
void assign(int __val, const error_category& __cat) _NOEXCEPT
@@ -347,7 +370,11 @@ public:
error_code&
>::type
operator=(_Ep __e) _NOEXCEPT
- {*this = make_error_code(__e); return *this;}
+ {
+ using __adl_only::make_error_code;
+ *this = make_error_code(__e);
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
@@ -381,14 +408,6 @@ make_error_code(errc __e) _NOEXCEPT
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();
@@ -402,12 +421,14 @@ operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
|| __y.category().equivalent(__x, __y.value());
}
+#if _LIBCPP_STD_VER <= 17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
{
return __y == __x;
}
+#endif
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -416,6 +437,8 @@ operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
return __x.category() == __y.category() && __x.value() == __y.value();
}
+#if _LIBCPP_STD_VER <= 17
+
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
@@ -436,6 +459,42 @@ bool
operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
{return !(__x == __y);}
+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());
+}
+
+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());
+}
+
+#else // _LIBCPP_STD_VER <= 17
+
+inline _LIBCPP_HIDE_FROM_ABI strong_ordering
+operator<=>(const error_code& __x, const error_code& __y) noexcept
+{
+ if (auto __c = __x.category() <=> __y.category(); __c != 0)
+ return __c;
+ return __x.value() <=> __y.value();
+}
+
+inline _LIBCPP_HIDE_FROM_ABI strong_ordering
+operator<=>(const error_condition& __x, const error_condition& __y) noexcept
+{
+ if (auto __c = __x.category() <=> __y.category(); __c != 0)
+ return __c;
+ return __x.value() <=> __y.value();
+}
+
+#endif // _LIBCPP_STD_VER <= 17
+
template <>
struct _LIBCPP_TEMPLATE_VIS hash<error_code>
: public __unary_function<error_code, size_t>
@@ -472,7 +531,7 @@ public:
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;
+ ~system_error() _NOEXCEPT override;
_LIBCPP_INLINE_VISIBILITY
const error_code& code() const _NOEXCEPT {return __ec_;}
diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h
index c65091708a9a..e6f0a4ab2611 100644
--- a/libcxx/include/tgmath.h
+++ b/libcxx/include/tgmath.h
@@ -24,13 +24,11 @@
#endif
#ifdef __cplusplus
-
-#include <ctgmath>
-
-#else // __cplusplus
-
-#include_next <tgmath.h>
-
-#endif // __cplusplus
+# include <ctgmath>
+#else
+# if __has_include_next(<tgmath.h>)
+# include_next <tgmath.h>
+# endif
+#endif
#endif // _LIBCPP_TGMATH_H
diff --git a/libcxx/include/thread b/libcxx/include/thread
index 1c8eb198986d..7a1117f555a7 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -53,11 +53,12 @@ public:
};
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;
+bool operator!=(thread::id x, thread::id y) noexcept; // removed in C++20
+bool operator< (thread::id x, thread::id y) noexcept; // removed in C++20
+bool operator<=(thread::id x, thread::id y) noexcept; // removed in C++20
+bool operator> (thread::id x, thread::id y) noexcept; // removed in C++20
+bool operator>=(thread::id x, thread::id y) noexcept; // removed in C++20
+strong_ordering operator<=>(thread::id x, thread::id y) noexcept; // C++20
template<class charT, class traits>
basic_ostream<charT, traits>&
@@ -85,6 +86,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__functional/hash.h>
+#include <__memory/unique_ptr.h>
#include <__mutex_base>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>
@@ -92,18 +94,14 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#include <__utility/forward.h>
#include <cstddef>
#include <iosfwd>
-#include <memory>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <chrono>
-# include <functional>
-#endif
-
// standard-mandated includes
+
+// [thread.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -201,7 +199,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
{
_LIBCPP_ASSERT(get() == nullptr,
"Attempting to overwrite thread local data");
- __libcpp_tls_set(__key_, __p);
+ std::__libcpp_tls_set(__key_, __p);
}
template<>
@@ -235,7 +233,7 @@ public:
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> >
+ class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value> >
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
explicit thread(_Fp&& __f, _Args&&... __args);
#else // _LIBCPP_CXX03_LANG
@@ -328,7 +326,7 @@ struct __thread_invoke_pair {
};
template <class _Fp>
-void* __thread_proxy_cxx03(void* __vp)
+_LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp)
{
unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
__thread_local_data().set_pointer(__p->__tsp_.release());
@@ -361,7 +359,7 @@ namespace this_thread
_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);
template <class _Rep, class _Period>
-void
+_LIBCPP_HIDE_FROM_ABI void
sleep_for(const chrono::duration<_Rep, _Period>& __d)
{
if (__d > chrono::duration<_Rep, _Period>::zero())
@@ -385,7 +383,7 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d)
}
template <class _Clock, class _Duration>
-void
+_LIBCPP_HIDE_FROM_ABI void
sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
{
mutex __mut;
@@ -412,4 +410,12 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+# include <chrono>
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <functional>
+#endif
+
#endif // _LIBCPP_THREAD
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 79527cca5853..b0616bd94da5 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -205,10 +205,45 @@ template <class... Types>
#include <__compare/common_comparison_category.h>
#include <__compare/synth_three_way.h>
#include <__config>
+#include <__functional/invoke.h>
#include <__functional/unwrap_ref.h>
+#include <__fwd/array.h>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
-#include <__tuple>
+#include <__type_traits/apply_cv.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/copy_cvref.h>
+#include <__type_traits/disjunction.h>
+#include <__type_traits/is_arithmetic.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_copy_assignable.h>
+#include <__type_traits/is_copy_constructible.h>
+#include <__type_traits/is_default_constructible.h>
+#include <__type_traits/is_empty.h>
+#include <__type_traits/is_final.h>
+#include <__type_traits/is_implicitly_default_constructible.h>
+#include <__type_traits/is_move_assignable.h>
+#include <__type_traits/is_move_constructible.h>
+#include <__type_traits/is_nothrow_assignable.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_copy_assignable.h>
+#include <__type_traits/is_nothrow_copy_constructible.h>
+#include <__type_traits/is_nothrow_default_constructible.h>
+#include <__type_traits/is_nothrow_move_assignable.h>
+#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_swappable.h>
+#include <__type_traits/lazy.h>
+#include <__type_traits/maybe_const.h>
+#include <__type_traits/nat.h>
+#include <__type_traits/negation.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/remove_reference.h>
#include <__utility/forward.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
@@ -216,18 +251,11 @@ template <class... Types>
#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
#include <cstddef>
-#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <exception>
-# include <iosfwd>
-# include <new>
-# include <typeinfo>
-# include <utility>
-#endif
-
// standard-mandated includes
+
+// [tuple.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -247,7 +275,7 @@ template <size_t _Ip, class _Hp,
class __tuple_leaf;
template <size_t _Ip, class _Hp, bool _Ep>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
_NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
{
@@ -255,7 +283,7 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
}
template <size_t _Ip, class _Hp, bool _Ep>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
_NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
swap(__x.get(), __y.get());
@@ -275,7 +303,7 @@ class __tuple_leaf
#endif
}
- _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
__tuple_leaf& operator=(const __tuple_leaf&);
public:
_LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
@@ -307,33 +335,33 @@ public:
template <class _Tp,
class = __enable_if_t<
_And<
- _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
+ _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
is_constructible<_Hp, _Tp>
>::value
>
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: __value_(_VSTD::forward<_Tp>(__t), __a)
{static_assert(!is_reference<_Hp>::value,
@@ -342,28 +370,28 @@ public:
__tuple_leaf(const __tuple_leaf& __t) = default;
__tuple_leaf(__tuple_leaf&& __t) = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __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_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return __value_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 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
+ _LIBCPP_CONSTEXPR_SINCE_CXX14
__tuple_leaf& operator=(const __tuple_leaf&);
public:
_LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
@@ -386,12 +414,12 @@ public:
template <class _Tp,
class = __enable_if_t<
_And<
- _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
+ _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
is_constructible<_Hp, _Tp>
>::value
>
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
: _Hp(_VSTD::forward<_Tp>(__t)) {}
@@ -413,7 +441,7 @@ public:
__tuple_leaf(__tuple_leaf const &) = default;
__tuple_leaf(__tuple_leaf &&) = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
int
swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
{
@@ -421,18 +449,18 @@ public:
return 0;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
_VSTD::swap(*this, __rhs);
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);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
};
template <class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
void __swallow(_Tp&&...) _NOEXCEPT {}
template <class _Tp>
@@ -457,7 +485,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
template <size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit
__tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
@@ -470,7 +498,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
template <class _Alloc, size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit
__tuple_impl(allocator_arg_t, const _Alloc& __a,
__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
@@ -484,7 +512,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
template <class _Tuple,
class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
__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,
@@ -494,7 +522,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
template <class _Alloc, class _Tuple,
class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
__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,
@@ -505,14 +533,14 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
__tuple_impl(const __tuple_impl&) = default;
__tuple_impl(__tuple_impl&&) = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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))...);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
void swap(const __tuple_impl& __t) const
_NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
{
@@ -521,13 +549,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
};
template<class _Dest, class _Source, size_t ..._Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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))
@@ -541,13 +569,13 @@ class _LIBCPP_TEMPLATE_VIS tuple
_BaseT __base_;
- template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
- template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
- template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
- template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
public:
// [tuple.cnstr]
@@ -580,7 +608,7 @@ public:
_IsImpDefault<_Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, _Alloc const& __a)
: __base_(allocator_arg_t(), __a,
__tuple_indices<>(), __tuple_types<>(),
@@ -595,7 +623,7 @@ public:
_Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, _Alloc const& __a)
: __base_(allocator_arg_t(), __a,
__tuple_indices<>(), __tuple_types<>(),
@@ -610,7 +638,7 @@ public:
is_convertible<const _Tp&, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(const _Tp& ... __t)
_NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
@@ -627,7 +655,7 @@ public:
_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(const _Tp& ... __t)
_NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
@@ -644,7 +672,7 @@ public:
is_convertible<const _Tp&, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
@@ -661,7 +689,7 @@ public:
_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
@@ -673,7 +701,7 @@ public:
// 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 _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> { };
template <class ..._Up>
struct _EnableUTypesCtor : _And<
@@ -689,7 +717,7 @@ public:
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(_Up&&... __u)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
: __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
@@ -705,7 +733,7 @@ public:
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(_Up&&... __u)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
: __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
@@ -721,7 +749,7 @@ public:
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
@@ -737,7 +765,7 @@ public:
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
@@ -753,7 +781,7 @@ public:
template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
_And<is_copy_constructible<_Tp>...>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
: __base_(allocator_arg_t(), __alloc, __t)
{ }
@@ -761,14 +789,14 @@ public:
template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
_And<is_move_constructible<_Tp>...>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
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 _OtherTuple, class _DecayedOtherTuple = __uncvref_t<_OtherTuple>, class = void>
+ template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
struct _EnableCtorFromUTypesTuple : false_type {};
template <class _OtherTuple, class... _Up>
@@ -797,7 +825,7 @@ public:
is_convertible<const _Up&, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(const tuple<_Up...>& __t)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
: __base_(__t)
@@ -809,7 +837,7 @@ public:
_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(const tuple<_Up...>& __t)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
: __base_(__t)
@@ -821,7 +849,7 @@ public:
is_convertible<const _Up&, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
: __base_(allocator_arg_t(), __a, __t)
{ }
@@ -832,7 +860,7 @@ public:
_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
: __base_(allocator_arg_t(), __a, __t)
{ }
@@ -861,7 +889,7 @@ public:
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(tuple<_Up...>&& __t)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
: __base_(_VSTD::move(__t))
@@ -873,7 +901,7 @@ public:
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(tuple<_Up...>&& __t)
_NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
: __base_(_VSTD::move(__t))
@@ -885,7 +913,7 @@ public:
is_convertible<_Up, _Tp>... // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
: __base_(allocator_arg_t(), __a, _VSTD::move(__t))
{ }
@@ -896,7 +924,7 @@ public:
_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
: __base_(allocator_arg_t(), __a, _VSTD::move(__t))
{ }
@@ -920,7 +948,7 @@ public:
// tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
- template <template <class...> class Pred, class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ template <template <class...> class Pred, class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
struct _CtorPredicateFromPair : false_type{};
template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
@@ -935,7 +963,7 @@ public:
template <class _Pair>
struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
- template <class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
struct _BothImplicitlyConvertible : false_type{};
template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
@@ -950,7 +978,7 @@ public:
_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(const pair<_Up1, _Up2>& __p)
_NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
: __base_(__p)
@@ -962,7 +990,7 @@ public:
_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(const pair<_Up1, _Up2>& __p)
_NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
: __base_(__p)
@@ -974,7 +1002,7 @@ public:
_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
: __base_(allocator_arg_t(), __a, __p)
{ }
@@ -985,7 +1013,7 @@ public:
_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
: __base_(allocator_arg_t(), __a, __p)
{ }
@@ -1014,7 +1042,7 @@ public:
_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple(pair<_Up1, _Up2>&& __p)
_NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
: __base_(_VSTD::move(__p))
@@ -1026,7 +1054,7 @@ public:
_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
explicit tuple(pair<_Up1, _Up2>&& __p)
_NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
: __base_(_VSTD::move(__p))
@@ -1038,7 +1066,7 @@ public:
_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
: __base_(allocator_arg_t(), __a, _VSTD::move(__p))
{ }
@@ -1049,7 +1077,7 @@ public:
_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
>::value
, int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
: __base_(allocator_arg_t(), __a, _VSTD::move(__p))
{ }
@@ -1072,7 +1100,7 @@ public:
#endif // _LIBCPP_STD_VER > 20
// [tuple.assign]
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
_NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
{
@@ -1100,7 +1128,7 @@ public:
}
#endif // _LIBCPP_STD_VER > 20
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
_NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
{
@@ -1116,7 +1144,7 @@ public:
is_assignable<_Tp&, _Up const&>...
>::value
,int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(tuple<_Up...> const& __tuple)
_NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
{
@@ -1131,7 +1159,7 @@ public:
is_assignable<_Tp&, _Up>...
>::value
,int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(tuple<_Up...>&& __tuple)
_NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
{
@@ -1168,7 +1196,7 @@ public:
#endif // _LIBCPP_STD_VER > 20
template <template<class...> class Pred, bool _Const,
- class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
+ class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
struct _AssignPredicateFromPair : false_type {};
template <template<class...> class Pred, bool _Const,
@@ -1209,7 +1237,7 @@ public:
template<class _Up1, class _Up2, __enable_if_t<
_EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
,int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(pair<_Up1, _Up2> const& __pair)
_NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
{
@@ -1221,7 +1249,7 @@ public:
template<class _Up1, class _Up2, __enable_if_t<
_EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
,int> = 0>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(pair<_Up1, _Up2>&& __pair)
_NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
{
@@ -1237,7 +1265,7 @@ public:
is_assignable<_Tp&, _Up const&>...
>::value
> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(array<_Up, _Np> const& __array)
_NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
{
@@ -1253,7 +1281,7 @@ public:
is_assignable<_Tp&, _Up>...
>::value
> >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple& operator=(array<_Up, _Np>&& __array)
_NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
{
@@ -1264,7 +1292,7 @@ public:
}
// [tuple.swap]
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{__base_.swap(__t.__base_);}
@@ -1283,18 +1311,18 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr
tuple() _NOEXCEPT = default;
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(array<_Up, 0>) _NOEXCEPT {}
template <class _Alloc, class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
void swap(tuple&) _NOEXCEPT {}
#if _LIBCPP_STD_VER > 20
_LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
@@ -1329,7 +1357,7 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
#endif
template <class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
@@ -1348,7 +1376,7 @@ swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
// get
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>& __t) _NOEXCEPT
{
@@ -1357,7 +1385,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT
}
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>& __t) _NOEXCEPT
{
@@ -1366,7 +1394,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT
}
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&& __t) _NOEXCEPT
{
@@ -1376,7 +1404,7 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT
}
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(const tuple<_Tp...>&& __t) _NOEXCEPT
{
@@ -1402,7 +1430,7 @@ 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]);
+ __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
}
template <class _T1, class ..._Args>
@@ -1458,7 +1486,7 @@ constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
// tie
template <class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple<_Tp&...>
tie(_Tp&... __t) _NOEXCEPT
{
@@ -1469,7 +1497,7 @@ template <class _Up>
struct __ignore_t
{
template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
const __ignore_t& operator=(_Tp&&) const {return *this;}
};
@@ -1478,7 +1506,7 @@ namespace {
} // namespace
template <class... _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple<typename __unwrap_ref_decay<_Tp>::type...>
make_tuple(_Tp&&... __t)
{
@@ -1486,7 +1514,7 @@ make_tuple(_Tp&&... __t)
}
template <class... _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple<_Tp&&...>
forward_as_tuple(_Tp&&... __t) _NOEXCEPT
{
@@ -1497,7 +1525,7 @@ template <size_t _Ip>
struct __tuple_equal
{
template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
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);
@@ -1508,7 +1536,7 @@ template <>
struct __tuple_equal<0>
{
template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _Tp&, const _Up&)
{
return true;
@@ -1516,7 +1544,7 @@ struct __tuple_equal<0>
};
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1549,7 +1577,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
#else // _LIBCPP_STD_VER > 17
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1560,7 +1588,7 @@ template <size_t _Ip>
struct __tuple_less
{
template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _Tp& __x, const _Up& __y)
{
const size_t __idx = tuple_size<_Tp>::value - _Ip;
@@ -1576,7 +1604,7 @@ template <>
struct __tuple_less<0>
{
template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool operator()(const _Tp&, const _Up&)
{
return false;
@@ -1584,7 +1612,7 @@ struct __tuple_less<0>
};
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1593,7 +1621,7 @@ operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
}
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1601,7 +1629,7 @@ operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
}
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1609,7 +1637,7 @@ operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
}
template <class ..._Tp, class ..._Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
bool
operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
@@ -1638,7 +1666,7 @@ 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
+ typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
>::type;
};
@@ -1647,9 +1675,9 @@ 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
+ typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
>::type,
- __tuple_like<typename remove_reference<_Tuple1>::type>::value,
+ __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
_Tuple1, _Tuples...>
{
};
@@ -1659,7 +1687,7 @@ 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,
+ __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value, _Tuple0,
_Tuples...>
{
};
@@ -1670,7 +1698,7 @@ struct __tuple_cat_return<>
typedef _LIBCPP_NODEBUG tuple<> type;
};
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
tuple<>
tuple_cat()
{
@@ -1683,7 +1711,7 @@ 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 _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
typedef tuple<_Types..., typename __apply_cv<_Tuple0,
typename tuple_element<_I0, _T0>::type>::type&&...> type;
};
@@ -1694,9 +1722,8 @@ struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
: 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,
+ __libcpp_remove_reference_t<_Tuple0> >::type>::type&&...>,
+ typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
_Tuple1, _Tuples...>
{
};
@@ -1705,7 +1732,7 @@ 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
+ tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value
>::type, _Tuple0, _Tuples...>
{
};
@@ -1717,7 +1744,7 @@ 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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
@@ -1728,13 +1755,13 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
{
(void)__t; // avoid unused parameter warning on GCC when _I0 is empty
- typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
- typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
return __tuple_cat<
tuple<_Types...,
typename __apply_cv<_Tuple0, typename tuple_element<
@@ -1750,11 +1777,11 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
};
template <class _Tuple0, class... _Tuples>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
typename __tuple_cat_return<_Tuple0, _Tuples...>::type
tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
{
- typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
+ typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
return __tuple_cat<tuple<>, __tuple_indices<>,
typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
(tuple<>(), _VSTD::forward<_Tuple0>(__t0),
@@ -1767,7 +1794,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
pair<_T1, _T2>::pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
@@ -1824,4 +1851,13 @@ _LIBCPP_NOEXCEPT_RETURN(
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <exception>
+# include <iosfwd>
+# include <new>
+# include <type_traits>
+# include <typeinfo>
+# include <utility>
+#endif
+
#endif // _LIBCPP_TUPLE
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 3a086c595f92..7646f5805980 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -158,8 +158,8 @@ namespace std
// 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;
+ struct aligned_storage; // deprecated in C++23
+ template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23
template <class T> struct remove_cvref; // C++20
template <class T> struct decay;
@@ -419,6 +419,7 @@ namespace std
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__functional/invoke.h>
+#include <__fwd/hash.h> // This is https://llvm.org/PR56938
#include <__type_traits/add_const.h>
#include <__type_traits/add_cv.h>
#include <__type_traits/add_lvalue_reference.h>
@@ -429,11 +430,13 @@ namespace std
#include <__type_traits/aligned_union.h>
#include <__type_traits/alignment_of.h>
#include <__type_traits/apply_cv.h>
+#include <__type_traits/can_extract_key.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/common_type.h>
#include <__type_traits/conditional.h>
#include <__type_traits/conjunction.h>
#include <__type_traits/decay.h>
+#include <__type_traits/dependent_type.h>
#include <__type_traits/disjunction.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/extent.h>
@@ -448,6 +451,7 @@ namespace std
#include <__type_traits/is_base_of.h>
#include <__type_traits/is_bounded_array.h>
#include <__type_traits/is_callable.h>
+#include <__type_traits/is_char_like_type.h>
#include <__type_traits/is_class.h>
#include <__type_traits/is_compound.h>
#include <__type_traits/is_const.h>
@@ -464,6 +468,7 @@ namespace std
#include <__type_traits/is_floating_point.h>
#include <__type_traits/is_function.h>
#include <__type_traits/is_fundamental.h>
+#include <__type_traits/is_implicitly_default_constructible.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/is_literal_type.h>
#include <__type_traits/is_member_function_pointer.h>
@@ -492,7 +497,9 @@ namespace std
#include <__type_traits/is_scalar.h>
#include <__type_traits/is_scoped_enum.h>
#include <__type_traits/is_signed.h>
+#include <__type_traits/is_specialization.h>
#include <__type_traits/is_standard_layout.h>
+#include <__type_traits/is_swappable.h>
#include <__type_traits/is_trivial.h>
#include <__type_traits/is_trivially_assignable.h>
#include <__type_traits/is_trivially_constructible.h>
@@ -508,17 +515,21 @@ namespace std
#include <__type_traits/is_unsigned.h>
#include <__type_traits/is_void.h>
#include <__type_traits/is_volatile.h>
+#include <__type_traits/make_const_lvalue_ref.h>
#include <__type_traits/make_signed.h>
#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
#include <__type_traits/negation.h>
#include <__type_traits/rank.h>
#include <__type_traits/remove_all_extents.h>
#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_const_ref.h>
#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_extent.h>
#include <__type_traits/remove_pointer.h>
#include <__type_traits/remove_reference.h>
#include <__type_traits/remove_volatile.h>
+#include <__type_traits/result_of.h>
#include <__type_traits/type_identity.h>
#include <__type_traits/underlying_type.h>
#include <__type_traits/void_t.h>
@@ -531,280 +542,4 @@ namespace std
# pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
-
-// Member detector base
-
-template <class _Tp, bool>
-struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
-
-// is_integral
-
-template <class _Tp>
-struct __unconstref {
- typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
-};
-
-#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
-
-// result_of
-
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
-template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
-
-template <class _Fp, class ..._Args>
-class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
- : public __invoke_of<_Fp, _Args...>
-{
-};
-
-#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)
-
-// __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 __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; }
-
-// 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 {};
-
-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&;
-
-template<bool _Const, class _Tp>
-using __maybe_const = typename conditional<_Const, const _Tp, _Tp>::type;
-
-_LIBCPP_END_NAMESPACE_STD
-
#endif // _LIBCPP_TYPE_TRAITS
diff --git a/libcxx/include/typeindex b/libcxx/include/typeindex
index 5fb7b30ecfee..e3132c8cb856 100644
--- a/libcxx/include/typeindex
+++ b/libcxx/include/typeindex
@@ -23,11 +23,12 @@ 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; // removed in C++20
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;
+ strong_ordering operator<=>(const type_index& rhs) const noexcept; // C++20
size_t hash_code() const noexcept;
const char* name() const noexcept;
@@ -50,12 +51,6 @@ struct hash<type_index>
#include <typeinfo>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iosfwd>
-# include <new>
-# include <utility>
-#endif
-
// standard-mandated includes
#include <compare>
@@ -76,8 +71,10 @@ public:
bool operator==(const type_index& __y) const _NOEXCEPT
{return *__t_ == *__y.__t_;}
_LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_STD_VER <= 17
bool operator!=(const type_index& __y) const _NOEXCEPT
{return *__t_ != *__y.__t_;}
+#endif
_LIBCPP_INLINE_VISIBILITY
bool operator< (const type_index& __y) const _NOEXCEPT
{return __t_->before(*__y.__t_);}
@@ -90,6 +87,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator>=(const type_index& __y) const _NOEXCEPT
{return !__t_->before(*__y.__t_);}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_HIDE_FROM_ABI
+ strong_ordering operator<=>(const type_index& __y) const noexcept {
+ if (*__t_ == *__y.__t_)
+ return strong_ordering::equal;
+ if (__t_->before(*__y.__t_))
+ return strong_ordering::less;
+ return strong_ordering::greater;
+ }
+#endif
_LIBCPP_INLINE_VISIBILITY
size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
@@ -110,4 +117,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index>
_LIBCPP_END_NAMESPACE_STD
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
+# include <new>
+# include <utility>
+#endif
+
#endif // _LIBCPP_TYPEINDEX
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index a0ac527db782..443103939849 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -22,7 +22,7 @@ public:
virtual ~type_info();
bool operator==(const type_info& rhs) const noexcept;
- bool operator!=(const type_info& rhs) const noexcept;
+ bool operator!=(const type_info& rhs) const noexcept; // removed in C++20
bool before(const type_info& rhs) const noexcept;
size_t hash_code() const noexcept;
@@ -61,13 +61,10 @@ public:
#include <__config>
#include <cstddef>
#include <cstdint>
+#include <cstdlib>
#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
@@ -112,9 +109,11 @@ public:
return __compare(__arg) == 0;
}
+#if _LIBCPP_STD_VER <= 17
_LIBCPP_INLINE_VISIBILITY
bool operator!=(const type_info& __arg) const _NOEXCEPT
{ return !operator==(__arg); }
+#endif
};
#else // !defined(_LIBCPP_ABI_MICROSOFT)
@@ -174,8 +173,8 @@ public:
// 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
+ // Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
+# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
@@ -337,9 +336,11 @@ public:
return __impl::__eq(__type_name, __arg.__type_name);
}
+#if _LIBCPP_STD_VER <= 17
_LIBCPP_INLINE_VISIBILITY
bool operator!=(const type_info& __arg) const _NOEXCEPT
{ return !operator==(__arg); }
+#endif
};
#endif // defined(_LIBCPP_ABI_MICROSOFT)
@@ -349,8 +350,8 @@ class _LIBCPP_EXCEPTION_ABI bad_cast
public:
bad_cast() _NOEXCEPT;
bad_cast(const bad_cast&) _NOEXCEPT = default;
- virtual ~bad_cast() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ ~bad_cast() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
class _LIBCPP_EXCEPTION_ABI bad_typeid
@@ -358,14 +359,38 @@ class _LIBCPP_EXCEPTION_ABI bad_typeid
{
public:
bad_typeid() _NOEXCEPT;
- virtual ~bad_typeid() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ ~bad_typeid() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
} // namespace std
#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+
+namespace std {
+
+class bad_cast : public exception {
+public:
+ bad_cast() _NOEXCEPT : exception("bad cast") {}
+
+private:
+ bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}
+};
+
+class bad_typeid : public exception {
+public:
+ bad_typeid() _NOEXCEPT : exception("bad typeid") {}
+
+private:
+ bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}
+};
+
+} // namespace std
+
+#endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
void __throw_bad_cast()
diff --git a/libcxx/include/uchar.h b/libcxx/include/uchar.h
index bb152c72cb3c..3a51bb7a9f61 100644
--- a/libcxx/include/uchar.h
+++ b/libcxx/include/uchar.h
@@ -23,6 +23,8 @@ Types:
mbstate_t
size_t
+size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps); // since C++20
+size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps); // since C++20
size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index b2a12cb638d8..14f93bab36e1 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -525,18 +525,15 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__node_handle>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
#include <stdexcept>
#include <tuple>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <bit>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -822,16 +819,16 @@ struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
private:
- value_type __cc;
+ value_type __cc_;
public:
_LIBCPP_INLINE_VISIBILITY
value_type& __get_value()
{
#if _LIBCPP_STD_VER > 14
- return *_VSTD::launder(_VSTD::addressof(__cc));
+ return *_VSTD::launder(_VSTD::addressof(__cc_));
#else
- return __cc;
+ return __cc_;
#endif
}
@@ -839,9 +836,9 @@ public:
const value_type& __get_value() const
{
#if _LIBCPP_STD_VER > 14
- return *_VSTD::launder(_VSTD::addressof(__cc));
+ return *_VSTD::launder(_VSTD::addressof(__cc_));
#else
- return __cc;
+ return __cc_;
#endif
}
@@ -904,13 +901,13 @@ struct __hash_value_type
typedef pair<const key_type, mapped_type> value_type;
private:
- value_type __cc;
+ value_type __cc_;
public:
_LIBCPP_INLINE_VISIBILITY
- value_type& __get_value() { return __cc; }
+ value_type& __get_value() { return __cc_; }
_LIBCPP_INLINE_VISIBILITY
- const value_type& __get_value() const { return __cc; }
+ const value_type& __get_value() const { return __cc_; }
private:
~__hash_value_type();
@@ -1044,8 +1041,7 @@ 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 __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1062,6 +1058,10 @@ private:
typedef unique_ptr<__node, _Dp> __node_holder;
typedef allocator_traits<allocator_type> __alloc_traits;
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
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:
@@ -1149,7 +1149,7 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY
~unordered_map() {
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
}
_LIBCPP_INLINE_VISIBILITY
@@ -1886,7 +1886,7 @@ inline _LIBCPP_INLINE_VISIBILITY
#endif
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
@@ -1934,8 +1934,7 @@ 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 __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1952,7 +1951,12 @@ private:
static_assert((is_same<typename __node_traits::size_type,
typename __alloc_traits::size_type>::value),
"Allocator uses different size_type for different types");
-public:
+
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
+ public:
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
typedef typename __table::size_type size_type;
@@ -2037,7 +2041,7 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY
~unordered_multimap() {
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
}
_LIBCPP_INLINE_VISIBILITY
@@ -2592,7 +2596,7 @@ inline _LIBCPP_INLINE_VISIBILITY
#endif
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
@@ -2625,4 +2629,25 @@ operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
+using unordered_map =
+ std::unordered_map<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
+
+template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
+using unordered_multimap =
+ std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <bit>
+# include <concepts>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_UNORDERED_MAP
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index fc6e8e21c0cb..b4203c08a9b9 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -470,15 +470,13 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
+#include <__memory/allocator.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__node_handle>
+#include <__type_traits/is_allocator.h>
#include <__utility/forward.h>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <functional>
-# include <iterator>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -517,7 +515,11 @@ public:
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
-private:
+ static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
+ private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
@@ -611,7 +613,7 @@ public:
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~unordered_set() {
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
+ static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
}
_LIBCPP_INLINE_VISIBILITY
@@ -1130,7 +1132,7 @@ inline _LIBCPP_INLINE_VISIBILITY
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
@@ -1265,7 +1267,7 @@ public:
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~unordered_multiset() {
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
+ static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
}
_LIBCPP_INLINE_VISIBILITY
@@ -1768,7 +1770,7 @@ inline _LIBCPP_INLINE_VISIBILITY
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
-bool
+_LIBCPP_HIDE_FROM_ABI bool
operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
@@ -1801,4 +1803,22 @@ operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
+using unordered_set = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
+
+template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
+using unordered_multiset = std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <concepts>
+# include <functional>
+# include <iterator>
+#endif
+
#endif // _LIBCPP_UNORDERED_SET
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 7a1a45e334a3..a4d8cf853d20 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -42,6 +42,10 @@ 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 <typename T>
+[[nodiscard]] constexpr
+auto forward_like(auto&& x) noexcept -> see below; // since C++23
+
template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
template <class T>
@@ -80,19 +84,29 @@ struct pair
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> constexpr explicit(see below) pair(pair<U, V>&); // since C++23
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 U, class V>
+ constexpr explicit(see below) pair(const pair<U, V>&&); // since C++23
template <class... Args1, class... Args2>
pair(piecewise_construct_t, tuple<Args1...> first_args,
tuple<Args2...> second_args); // constexpr in C++20
+ constexpr const pair& operator=(const pair& p) const; // since C++23
template <class U, class V> pair& operator=(const pair<U, V>& p); // constexpr in C++20
+ template <class U, class V>
+ constexpr const pair& operator=(const pair<U, V>& p) const; // since C++23
pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
is_nothrow_move_assignable<T2>::value); // constexpr in C++20
+ constexpr const pair& operator=(pair&& p) const; // since C++23
template <class U, class V> pair& operator=(pair<U, V>&& p); // constexpr in C++20
+ template <class U, class V>
+ constexpr const pair& operator=(pair<U, V>&& p) const; // since C++23
void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
is_nothrow_swappable_v<T2>); // constexpr in C++20
+ constexpr void swap(const pair& p) const noexcept(see below); // since C++23
};
template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>
@@ -119,6 +133,9 @@ template <class T1, class T2>
void
swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
+template<class T1, class T2>
+constexpr void swap(const pair<T1, T2>& x, const pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // since C++23
+
struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
@@ -222,13 +239,14 @@ template <class T>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <__tuple>
#include <__utility/as_const.h>
#include <__utility/auto_cast.h>
#include <__utility/cmp.h>
#include <__utility/declval.h>
+#include <__utility/exception_guard.h>
#include <__utility/exchange.h>
#include <__utility/forward.h>
+#include <__utility/forward_like.h>
#include <__utility/in_place.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
@@ -238,21 +256,27 @@ template <class T>
#include <__utility/rel_ops.h>
#include <__utility/swap.h>
#include <__utility/to_underlying.h>
-#include <__utility/transaction.h>
#include <__utility/unreachable.h>
-#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <iosfwd>
-#endif
-
// standard-mandated includes
+
+// [utility.syn]
#include <compare>
#include <initializer_list>
+// [tuple.helper]
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <cstdlib>
+# include <iosfwd>
+# include <type_traits>
+#endif
+
#endif // _LIBCPP_UTILITY
diff --git a/libcxx/include/valarray b/libcxx/include/valarray
index 6f8a3b84197b..92521ed3819c 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -353,6 +353,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
#include <__functional/operations.h>
#include <__memory/allocator.h>
#include <__memory/uninitialized_algorithms.h>
+#include <__type_traits/remove_reference.h>
#include <__utility/move.h>
#include <__utility/swap.h>
#include <cmath>
@@ -360,12 +361,9 @@ template <class T> unspecified2 end(const valarray<T>& v);
#include <new>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <functional>
-#endif
-
// standard-mandated includes
+
+// [valarray.syn]
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -548,7 +546,7 @@ struct __abs_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return abs(__x);}
+ {return std::abs(__x);}
};
template <class _Tp>
@@ -557,7 +555,7 @@ struct __acos_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return acos(__x);}
+ {return std::acos(__x);}
};
template <class _Tp>
@@ -566,7 +564,7 @@ struct __asin_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return asin(__x);}
+ {return std::asin(__x);}
};
template <class _Tp>
@@ -575,7 +573,7 @@ struct __atan_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return atan(__x);}
+ {return std::atan(__x);}
};
template <class _Tp>
@@ -584,7 +582,7 @@ struct __atan2_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return atan2(__x, __y);}
+ {return std::atan2(__x, __y);}
};
template <class _Tp>
@@ -593,7 +591,7 @@ struct __cos_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return cos(__x);}
+ {return std::cos(__x);}
};
template <class _Tp>
@@ -602,7 +600,7 @@ struct __cosh_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return cosh(__x);}
+ {return std::cosh(__x);}
};
template <class _Tp>
@@ -611,7 +609,7 @@ struct __exp_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return exp(__x);}
+ {return std::exp(__x);}
};
template <class _Tp>
@@ -620,7 +618,7 @@ struct __log_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return log(__x);}
+ {return std::log(__x);}
};
template <class _Tp>
@@ -629,7 +627,7 @@ struct __log10_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return log10(__x);}
+ {return std::log10(__x);}
};
template <class _Tp>
@@ -638,7 +636,7 @@ struct __pow_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return pow(__x, __y);}
+ {return std::pow(__x, __y);}
};
template <class _Tp>
@@ -647,7 +645,7 @@ struct __sin_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return sin(__x);}
+ {return std::sin(__x);}
};
template <class _Tp>
@@ -656,7 +654,7 @@ struct __sinh_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return sinh(__x);}
+ {return std::sinh(__x);}
};
template <class _Tp>
@@ -665,7 +663,7 @@ struct __sqrt_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return sqrt(__x);}
+ {return std::sqrt(__x);}
};
template <class _Tp>
@@ -674,7 +672,7 @@ struct __tan_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return tan(__x);}
+ {return std::tan(__x);}
};
template <class _Tp>
@@ -683,13 +681,13 @@ struct __tanh_expr
typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
- {return tanh(__x);}
+ {return std::tanh(__x);}
};
template <class _ValExpr>
class __slice_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
typedef value_type __result_type;
@@ -729,7 +727,7 @@ class __indirect_expr;
template <class _ValExpr>
class __shift_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
typedef value_type __result_type;
@@ -772,7 +770,7 @@ public:
template <class _ValExpr>
class __cshift_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
typedef value_type __result_type;
@@ -2247,7 +2245,7 @@ mask_array<_Tp>::operator=(const value_type& __x) const
template <class _ValExpr>
class __mask_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
typedef value_type __result_type;
@@ -2610,7 +2608,7 @@ indirect_array<_Tp>::operator=(const value_type& __x) const
template <class _ValExpr>
class __indirect_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
typedef value_type __result_type;
@@ -2650,7 +2648,7 @@ public:
template<class _ValExpr>
class __val_expr
{
- typedef typename remove_reference<_ValExpr>::type _RmExpr;
+ typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
_ValExpr __expr_;
public:
@@ -4932,4 +4930,11 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <concepts>
+# include <cstring>
+# include <functional>
+#endif
+
#endif // _LIBCPP_VALARRAY
diff --git a/libcxx/include/variant b/libcxx/include/variant
index b74416b62d91..13c89822ca77 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -22,8 +22,8 @@ namespace std {
// 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
+ constexpr variant(const variant&);
+ constexpr variant(variant&&) noexcept(see below);
template <class T> constexpr variant(T&&) noexcept(see below);
@@ -45,8 +45,8 @@ namespace std {
~variant();
// 20.7.2.3, assignment
- variant& operator=(const variant&); // constexpr in C++20
- variant& operator=(variant&&) noexcept(see below); // constexpr in C++20
+ constexpr variant& operator=(const variant&);
+ constexpr variant& operator=(variant&&) noexcept(see below);
template <class T> variant& operator=(T&&) noexcept(see below);
@@ -165,6 +165,10 @@ namespace std {
template <class... Types>
constexpr bool operator>=(const variant<Types...>&, const variant<Types...>&);
+ template <class... Types> requires (three_way_comparable<Types> && ...)
+ constexpr common_comparison_category_t<compare_three_way_result_t<Types>...>
+ operator<=>(const variant<Types...>&, const variant<Types...>&); // since C++20
+
// 20.7.6, visitation
template <class Visitor, class... Variants>
constexpr see below visit(Visitor&&, Variants&&...);
@@ -176,12 +180,13 @@ namespace std {
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;
+ constexpr bool operator!=(monostate, monostate) noexcept; // until C++20
+ constexpr bool operator<(monostate, monostate) noexcept; // until C++20
+ constexpr bool operator>(monostate, monostate) noexcept; // until C++20
+ constexpr bool operator<=(monostate, monostate) noexcept; // until C++20
+ constexpr bool operator>=(monostate, monostate) noexcept; // until C++20
+ constexpr strong_ordering operator<=>(monostate, monostate) noexcept; // since C++20
// 20.7.9, specialized algorithms
template <class... Types>
@@ -201,11 +206,31 @@ namespace std {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
+#include <__compare/common_comparison_category.h>
+#include <__compare/compare_three_way_result.h>
+#include <__compare/three_way_comparable.h>
#include <__config>
#include <__functional/hash.h>
+#include <__functional/invoke.h>
#include <__functional/operations.h>
#include <__functional/unary_function.h>
-#include <__tuple>
+#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv.h>
+#include <__type_traits/add_pointer.h>
+#include <__type_traits/add_volatile.h>
+#include <__type_traits/dependent_type.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_destructible.h>
+#include <__type_traits/is_nothrow_move_constructible.h>
+#include <__type_traits/is_trivially_copy_assignable.h>
+#include <__type_traits/is_trivially_copy_constructible.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__type_traits/is_trivially_move_assignable.h>
+#include <__type_traits/is_trivially_move_constructible.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/remove_const.h>
+#include <__type_traits/type_identity.h>
+#include <__type_traits/void_t.h>
#include <__utility/forward.h>
#include <__utility/in_place.h>
#include <__utility/move.h>
@@ -216,15 +241,11 @@ namespace std {
#include <limits>
#include <new>
#include <tuple>
-#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <typeinfo>
-# include <utility>
-#endif
-
// standard-mandated includes
+
+// [variant.syn]
#include <compare>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -238,7 +259,7 @@ 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;
+ const char* what() const _NOEXCEPT override;
};
} // namespace std
@@ -261,7 +282,7 @@ struct __farray {
};
_LIBCPP_NORETURN
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
void __throw_bad_variant_access() {
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -320,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
inline constexpr size_t variant_npos = static_cast<size_t>(-1);
-constexpr int __choose_index_type(unsigned int __num_elem) {
+_LIBCPP_HIDE_FROM_ABI 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())
@@ -372,7 +393,7 @@ __as_variant(const variant<_Types...>&& __vs) noexcept {
namespace __find_detail {
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr size_t __find_index() {
constexpr bool __matches[] = {is_same_v<_Tp, _Types>...};
size_t __result = __not_found;
@@ -417,7 +438,7 @@ constexpr _Trait __trait =
? _Trait::_TriviallyAvailable
: _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable;
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
_Trait __result = _Trait::_TriviallyAvailable;
for (_Trait __t : __traits) {
@@ -431,24 +452,24 @@ constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
template <typename... _Types>
struct __traits {
static constexpr _Trait __copy_constructible_trait =
- __common_trait({__trait<_Types,
+ __variant_detail::__common_trait({__trait<_Types,
is_trivially_copy_constructible,
is_copy_constructible>...});
static constexpr _Trait __move_constructible_trait =
- __common_trait({__trait<_Types,
+ __variant_detail::__common_trait({__trait<_Types,
is_trivially_move_constructible,
is_move_constructible>...});
- static constexpr _Trait __copy_assignable_trait = __common_trait(
+ static constexpr _Trait __copy_assignable_trait = __variant_detail::__common_trait(
{__copy_constructible_trait,
__trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});
- static constexpr _Trait __move_assignable_trait = __common_trait(
+ static constexpr _Trait __move_assignable_trait = __variant_detail::__common_trait(
{__move_constructible_trait,
__trait<_Types, is_trivially_move_assignable, is_move_assignable>...});
- static constexpr _Trait __destructible_trait = __common_trait(
+ static constexpr _Trait __destructible_trait = __variant_detail::__common_trait(
{__trait<_Types, is_trivially_destructible, is_destructible>...});
};
@@ -456,13 +477,13 @@ namespace __access {
struct __union {
template <class _Vp>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
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>);
}
@@ -470,7 +491,7 @@ struct __union {
struct __base {
template <size_t _Ip, class _Vp>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto&& __get_alt(_Vp&& __v) {
return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data,
in_place_index<_Ip>);
@@ -479,9 +500,9 @@ struct __base {
struct __variant {
template <size_t _Ip, class _Vp>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto&& __get_alt(_Vp&& __v) {
- return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl);
+ return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl_);
}
};
@@ -491,7 +512,7 @@ namespace __visitation {
struct __base {
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr decltype(auto)
__visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
constexpr auto __fdiagonal =
@@ -502,7 +523,7 @@ struct __base {
}
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
_Vs&&... __vs) {
constexpr auto __fmatrix =
@@ -515,11 +536,11 @@ struct __base {
private:
template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }
template <class _Tp, size_t _Np, typename... _Indices>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,
size_t __index, _Indices... __indices) {
return __at(__elems[__index], __indices...);
@@ -533,17 +554,17 @@ private:
}
template <class... _Fs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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)>;
+ __std_visit_visitor_return_type_check<__remove_cvref_t<_Fs>...>();
+ using __result = __farray<common_type_t<__remove_cvref_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
+ _LIBCPP_HIDE_FROM_ABI
static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
return _VSTD::__invoke(
static_cast<_Fp>(__f),
@@ -552,40 +573,40 @@ private:
};
template <class _Fp, class... _Vs, size_t... _Is>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto __make_fdiagonal_impl() {
return __make_dispatch<_Fp, _Vs...>(
index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
}
template <class _Fp, class... _Vs, size_t... _Is>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto __make_fdiagonal() {
- constexpr size_t _Np = __uncvref_t<_Vp>::__size();
- static_assert(__all<(_Np == __uncvref_t<_Vs>::__size())...>::value);
+ constexpr size_t _Np = __remove_cvref_t<_Vp>::__size();
+ static_assert(__all<(_Np == __remove_cvref_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
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>,
index_sequence<_Js...>,
_Ls... __ls) {
@@ -594,34 +615,34 @@ private:
}
template <class _Fp, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto __make_fmatrix() {
return __make_fmatrix_impl<_Fp, _Vs...>(
- index_sequence<>{}, make_index_sequence<__uncvref_t<_Vs>::__size()>{}...);
+ index_sequence<>{}, make_index_sequence<__remove_cvref_t<_Vs>::__size()>{}...);
}
};
struct __variant {
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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...);
+ _VSTD::forward<_Vs>(__vs).__impl_...);
}
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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...);
+ _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl_...);
}
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr decltype(auto)
__visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
return __visit_alt_at(
@@ -631,7 +652,7 @@ struct __variant {
}
template <class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr decltype(auto) __visit_value(_Visitor&& __visitor,
_Vs&&... __vs) {
return __visit_alt(
@@ -641,7 +662,7 @@ struct __variant {
#if _LIBCPP_STD_VER > 17
template <class _Rp, class _Visitor, class... _Vs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr _Rp __visit_value(_Visitor&& __visitor,
_Vs&&... __vs) {
return __visit_alt(
@@ -660,7 +681,7 @@ private:
template <class _Visitor>
struct __value_visitor {
template <class... _Alts>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr decltype(auto) operator()(_Alts&&... __alts) const {
__std_visit_exhaustive_visitor_check<
_Visitor,
@@ -675,7 +696,7 @@ private:
template <class _Rp, class _Visitor>
struct __value_visitor_return_type {
template <class... _Alts>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr _Rp operator()(_Alts&&... __alts) const {
__std_visit_exhaustive_visitor_check<
_Visitor,
@@ -695,14 +716,14 @@ private:
#endif
template <class _Visitor>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};
}
@@ -716,7 +737,7 @@ struct _LIBCPP_TEMPLATE_VIS __alt {
using __value_type = _Tp;
template <class... _Args>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
explicit constexpr __alt(in_place_t, _Args&&... __args)
: __value(_VSTD::forward<_Args>(__args)...) {}
@@ -731,21 +752,21 @@ 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, \
+ union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \
_Index, \
_Tp, \
_Types...> { \
public: \
- inline _LIBCPP_INLINE_VISIBILITY \
+ _LIBCPP_HIDE_FROM_ABI \
explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
\
template <class... _Args> \
- inline _LIBCPP_INLINE_VISIBILITY \
+ _LIBCPP_HIDE_FROM_ABI \
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 \
+ _LIBCPP_HIDE_FROM_ABI \
explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
: __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \
\
@@ -776,41 +797,41 @@ class _LIBCPP_TEMPLATE_VIS __base {
public:
using __index_t = __variant_index_t<sizeof...(_Types)>;
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
explicit constexpr __base(__valueless_t __tag) noexcept
: __data(__tag), __index(__variant_npos<__index_t>) {}
template <size_t _Ip, class... _Args>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_HIDE_FROM_ABI
constexpr bool valueless_by_exception() const noexcept {
return index() == variant_npos;
}
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr size_t index() const noexcept {
return __index == __variant_npos<__index_t> ? variant_npos : __index;
}
protected:
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr auto&& __as_base() & { return *this; }
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr auto&& __as_base() && { return _VSTD::move(*this); }
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr auto&& __as_base() const & { return *this; }
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr auto&& __as_base() const && { return _VSTD::move(*this); }
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static constexpr size_t __size() { return sizeof...(_Types); }
__union<_DestructibleTrait, 0, _Types...> __data;
@@ -842,7 +863,7 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
__dtor& operator=(__dtor&&) = default; \
\
protected: \
- inline _LIBCPP_INLINE_VISIBILITY \
+ inline _LIBCPP_HIDE_FROM_ABI \
destroy \
}
@@ -858,7 +879,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(
if (!this->valueless_by_exception()) {
__visitation::__base::__visit_alt(
[](auto& __alt) noexcept {
- using __alt_type = __uncvref_t<decltype(__alt)>;
+ using __alt_type = __remove_cvref_t<decltype(__alt)>;
__alt.~__alt_type();
},
*this);
@@ -883,7 +904,7 @@ public:
protected:
template <size_t _Ip, class _Tp, class... _Args>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {
::new ((void*)_VSTD::addressof(__a))
__alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...);
@@ -891,7 +912,7 @@ protected:
}
template <class _Rhs>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
__lhs.__destroy();
if (!__rhs.valueless_by_exception()) {
@@ -954,7 +975,7 @@ 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...>, \
+ class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \
copy_constructible_trait> \
: public __move_constructor<__traits<_Types...>> { \
using __base_type = __move_constructor<__traits<_Types...>>; \
@@ -996,7 +1017,7 @@ public:
using __base_type::operator=;
template <size_t _Ip, class... _Args>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
auto& __emplace(_Args&&... __args) {
this->__destroy();
auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this),
@@ -1007,7 +1028,7 @@ public:
protected:
template <size_t _Ip, class _Tp, class _Arg>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
if (this->index() == _Ip) {
__a.__value = _VSTD::forward<_Arg>(__arg);
@@ -1028,7 +1049,7 @@ protected:
}
template <class _That>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void __generic_assign(_That&& __that) {
if (this->valueless_by_exception() && __that.valueless_by_exception()) {
// do nothing.
@@ -1053,7 +1074,7 @@ 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...>, \
+ class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \
move_assignable_trait> \
: public __assignment<__traits<_Types...>> { \
using __base_type = __assignment<__traits<_Types...>>; \
@@ -1094,7 +1115,7 @@ 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...>, \
+ class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \
copy_assignable_trait> \
: public __move_assignment<__traits<_Types...>> { \
using __base_type = __move_assignment<__traits<_Types...>>; \
@@ -1140,13 +1161,13 @@ public:
__impl& operator=(__impl&&) = default;
template <size_t _Ip, class _Arg>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void __assign(_Arg&& __arg) {
this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
_VSTD::forward<_Arg>(__arg));
}
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI
void __swap(__impl& __that) {
if (this->valueless_by_exception() && __that.valueless_by_exception()) {
// do nothing.
@@ -1192,7 +1213,7 @@ public:
}
private:
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI
bool __move_nothrow() const {
constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};
return this->valueless_by_exception() || __results[this->index()];
@@ -1208,7 +1229,7 @@ struct __narrowing_check {
template <class _Dest>
static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
template <class _Dest, class _Source>
- using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
+ using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({std::declval<_Source>()}));
};
template <class _Dest, class _Source>
@@ -1230,7 +1251,7 @@ struct __overload {
template <class _Tp, size_t>
struct __overload_bool {
- template <class _Up, class _Ap = __uncvref_t<_Up>>
+ template <class _Up, class _Ap = __remove_cvref_t<_Up>>
auto operator()(bool, _Up&&) const
-> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
};
@@ -1298,36 +1319,36 @@ public:
enable_if_t<__dependent_type<is_default_constructible<__first_type>,
_Dummy>::value,
int> = 0>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
- : __impl(in_place_index<0>) {}
+ : __impl_(in_place_index<0>) {}
- variant(const variant&) = default;
- variant(variant&&) = default;
+ constexpr variant(const variant&) = default;
+ constexpr 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,
+ enable_if_t<!is_same_v<__remove_cvref_t<_Arg>, variant>, int> = 0,
+ enable_if_t<!__is_inplace_type<__remove_cvref_t<_Arg>>::value, int> = 0,
+ enable_if_t<!__is_inplace_index<__remove_cvref_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
+ _LIBCPP_HIDE_FROM_ABI
constexpr variant(_Arg&& __arg) noexcept(
is_nothrow_constructible_v<_Tp, _Arg>)
- : __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__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
+ _LIBCPP_HIDE_FROM_ABI
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)...) {}
+ : __impl_(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
template <
size_t _Ip,
@@ -1337,13 +1358,13 @@ public:
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
+ _LIBCPP_HIDE_FROM_ABI
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)...) {}
+ : __impl_(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
template <
class _Tp,
@@ -1351,10 +1372,10 @@ public:
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
+ _LIBCPP_HIDE_FROM_ABI
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)...) {}
+ : __impl_(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
template <
class _Tp,
@@ -1364,32 +1385,32 @@ public:
__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
+ _LIBCPP_HIDE_FROM_ABI
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)...) {}
+ : __impl_(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
~variant() = default;
- variant& operator=(const variant&) = default;
- variant& operator=(variant&&) = default;
+ constexpr variant& operator=(const variant&) = default;
+ constexpr variant& operator=(variant&&) = default;
template <
class _Arg,
- enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
+ enable_if_t<!is_same_v<__remove_cvref_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
+ _LIBCPP_HIDE_FROM_ABI
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));
+ __impl_.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));
return *this;
}
@@ -1399,9 +1420,9 @@ public:
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
+ _LIBCPP_HIDE_FROM_ABI
_Tp& emplace(_Args&&... __args) {
- return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
+ return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
}
template <
@@ -1412,9 +1433,9 @@ public:
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
+ _LIBCPP_HIDE_FROM_ABI
_Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
- return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
+ return __impl_.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
}
template <
@@ -1423,9 +1444,9 @@ public:
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
+ _LIBCPP_HIDE_FROM_ABI
_Tp& emplace(_Args&&... __args) {
- return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
+ return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
}
template <
@@ -1436,18 +1457,18 @@ public:
__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
+ _LIBCPP_HIDE_FROM_ABI
_Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
- return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
+ return __impl_.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
}
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
constexpr bool valueless_by_exception() const noexcept {
- return __impl.valueless_by_exception();
+ return __impl_.valueless_by_exception();
}
- inline _LIBCPP_INLINE_VISIBILITY
- constexpr size_t index() const noexcept { return __impl.index(); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr size_t index() const noexcept { return __impl_.index(); }
template <
bool _Dummy = true,
@@ -1456,85 +1477,85 @@ public:
__dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
__dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
int> = 0>
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
void swap(variant& __that) noexcept(
__all<(is_nothrow_move_constructible_v<_Types> &&
is_nothrow_swappable_v<_Types>)...>::value) {
- __impl.__swap(__that.__impl);
+ __impl_.__swap(__that.__impl_);
}
private:
- __variant_detail::__impl<_Types...> __impl;
+ __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
+_LIBCPP_HIDE_FROM_ABI
constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept {
return __v.index() == _Ip;
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {
- return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+ return std::__holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <size_t _Ip, class _Vp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr auto&& __generic_get(_Vp&& __v) {
using __variant_detail::__access::__variant;
- if (!__holds_alternative<_Ip>(__v)) {
+ if (!std::__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_HIDE_FROM_ABI
_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);
+ return std::__generic_get<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_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));
+ return std::__generic_get<_Ip>(_VSTD::move(__v));
}
template <size_t _Ip, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_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);
+ return std::__generic_get<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_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));
+ return std::__generic_get<_Ip>(_VSTD::move(__v));
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp& get(variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
@@ -1542,7 +1563,7 @@ constexpr _Tp& get(variant<_Types...>& __v) {
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp&& get(variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
@@ -1551,7 +1572,7 @@ constexpr _Tp&& get(variant<_Types...>&& __v) {
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp& get(const variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
@@ -1559,7 +1580,7 @@ constexpr const _Tp& get(const variant<_Types...>& __v) {
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp&& get(const variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
@@ -1568,34 +1589,34 @@ constexpr const _Tp&& get(const variant<_Types...>&& __v) {
}
template <size_t _Ip, class _Vp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr auto* __generic_get_if(_Vp* __v) noexcept {
using __variant_detail::__access::__variant;
- return __v && __holds_alternative<_Ip>(*__v)
+ return __v && std::__holds_alternative<_Ip>(*__v)
? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value)
: nullptr;
}
template <size_t _Ip, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
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);
+ return std::__generic_get_if<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
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);
+ return std::__generic_get_if<_Ip>(__v);
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr add_pointer_t<_Tp>
get_if(variant<_Types...>* __v) noexcept {
static_assert(!is_void_v<_Tp>);
@@ -1603,7 +1624,7 @@ get_if(variant<_Types...>* __v) noexcept {
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr add_pointer_t<const _Tp>
get_if(const variant<_Types...>* __v) noexcept {
static_assert(!is_void_v<_Tp>);
@@ -1613,7 +1634,8 @@ get_if(const variant<_Types...>* __v) noexcept {
template <class _Operator>
struct __convert_to_bool {
template <class _T1, class _T2>
- _LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
+ _LIBCPP_HIDE_FROM_ABI
+ 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));
@@ -1621,7 +1643,7 @@ struct __convert_to_bool {
};
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator==(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1630,8 +1652,29 @@ constexpr bool operator==(const variant<_Types...>& __lhs,
return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);
}
+# if _LIBCPP_STD_VER > 17
+
+template <class... _Types> requires (three_way_comparable<_Types> && ...)
+_LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<compare_three_way_result_t<_Types>...>
+operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
+ using __variant_detail::__visitation::__variant;
+ using __result_t = common_comparison_category_t<compare_three_way_result_t<_Types>...>;
+ if (__lhs.valueless_by_exception() && __rhs.valueless_by_exception())
+ return strong_ordering::equal;
+ if (__lhs.valueless_by_exception())
+ return strong_ordering::less;
+ if (__rhs.valueless_by_exception())
+ return strong_ordering::greater;
+ if (auto __c = __lhs.index() <=> __rhs.index(); __c != 0)
+ return __c;
+ auto __three_way = []<class _Type>(const _Type& __v, const _Type& __w) -> __result_t { return __v <=> __w; };
+ return __variant::__visit_value_at(__lhs.index(), __three_way, __lhs, __rhs);
+}
+
+# endif // _LIBCPP_STD_VER > 17
+
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator!=(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1642,7 +1685,7 @@ constexpr bool operator!=(const variant<_Types...>& __lhs,
}
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator<(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1654,7 +1697,7 @@ constexpr bool operator<(const variant<_Types...>& __lhs,
}
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator>(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1666,7 +1709,7 @@ constexpr bool operator>(const variant<_Types...>& __lhs,
}
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator<=(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1679,7 +1722,7 @@ constexpr bool operator<=(const variant<_Types...>& __lhs,
}
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr bool operator>=(const variant<_Types...>& __lhs,
const variant<_Types...>& __rhs) {
using __variant_detail::__visitation::__variant;
@@ -1692,9 +1735,9 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,
}
template <class... _Vs>
-inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void
- __throw_if_valueless(_Vs&&... __vs) {
+_LIBCPP_HIDE_FROM_ABI
+_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) {
@@ -1704,10 +1747,10 @@ inline _LIBCPP_INLINE_VISIBILITY
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) {
+ typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
+_LIBCPP_HIDE_FROM_ABI
+_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),
@@ -1717,10 +1760,10 @@ inline _LIBCPP_INLINE_VISIBILITY
#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) {
+ typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
+_LIBCPP_HIDE_FROM_ABI
+_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),
@@ -1729,7 +1772,7 @@ inline _LIBCPP_INLINE_VISIBILITY
#endif
template <class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)
noexcept(noexcept(__lhs.swap(__rhs)))
-> decltype( __lhs.swap(__rhs))
@@ -1741,7 +1784,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<
using argument_type = variant<_Types...>;
using result_type = size_t;
- inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
result_type operator()(const argument_type& __v) const {
using __variant_detail::__visitation::__variant;
size_t __res =
@@ -1749,13 +1792,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<
? 299792458 // Random value chosen by the universe upon creation
: __variant::__visit_alt(
[](const auto& __alt) {
- using __alt_type = __uncvref_t<decltype(__alt)>;
+ using __alt_type = __remove_cvref_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()));
+ return std::__hash_combine(__res, hash<size_t>{}(__v.index()));
}
};
@@ -1763,22 +1806,22 @@ struct _LIBCPP_TEMPLATE_VIS hash<
// 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
+_LIBCPP_HIDE_FROM_ABI
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
+_LIBCPP_HIDE_FROM_ABI
constexpr auto&& __unchecked_get(const variant<_Types...>& __v) noexcept {
- return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+ return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <class _Tp, class... _Types>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
constexpr auto&& __unchecked_get(variant<_Types...>& __v) noexcept {
- return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+ return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
#endif // _LIBCPP_STD_VER > 14
@@ -1787,4 +1830,10 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <type_traits>
+# include <typeinfo>
+# include <utility>
+#endif
+
#endif // _LIBCPP_VARIANT
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 30030f85e43c..4b7ae130a7bc 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -267,6 +267,13 @@ template <class T, class Allocator, class Predicate>
typename vector<T, Allocator>::size_type
erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
+
+template<class T>
+ inline constexpr bool is-vector-bool-reference = see below; // exposition only, since C++23
+
+template<class T, class charT> requires is-vector-bool-reference<T> // Since C++23
+ struct formatter<T, charT>;
+
} // std
*/
@@ -281,9 +288,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/unwrap_iter.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__bit_reference>
+#include <__concepts/same_as.h>
#include <__config>
#include <__debug>
#include <__format/enable_insertable.h>
+#include <__format/formatter.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
#include <__iterator/advance.h>
@@ -293,7 +302,13 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__memory/allocate_at_least.h>
#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
+#include <__memory/temp_value.h>
+#include <__memory/uninitialized_algorithms.h>
+#include <__memory_resource/polymorphic_allocator.h>
#include <__split_buffer>
+#include <__type_traits/is_allocator.h>
+#include <__type_traits/noexcept_move_assign_container.h>
+#include <__utility/exception_guard.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/swap.h>
@@ -302,17 +317,10 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <cstring>
#include <iosfwd> // for forward declaration of vector
#include <limits>
-#include <memory>
#include <stdexcept>
#include <type_traits>
#include <version>
-#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-# include <algorithm>
-# include <typeinfo>
-# include <utility>
-#endif
-
// standard-mandated includes
// [iterator.range]
@@ -352,20 +360,25 @@ public:
typedef typename __alloc_traits::difference_type difference_type;
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
+ // TODO: Implement iterator bounds checking without requiring the global database.
typedef __wrap_iter<pointer> iterator;
typedef __wrap_iter<const_pointer> const_iterator;
- typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
- typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::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
+ static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
@@ -373,19 +386,20 @@ public:
#endif
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
}
- explicit vector(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a);
#endif
- vector(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
@@ -393,64 +407,72 @@ public:
}
}
- template <class _InputIterator>
- vector(_InputIterator __first,
- typename enable_if<__is_exactly_cpp17_input_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_exactly_cpp17_input_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);
+ template <class _InputIterator,
+ __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
+ template <class _InputIterator,
+ __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+
+ template <
+ class _ForwardIterator,
+ __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
+
+ template <class _ForwardIterator,
+ __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
- ~vector()
- {
- __annotate_delete();
- std::__debug_db_erase_c(this);
+private:
+ class __destroy_vector {
+ public:
+ _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
- if (this->__begin_ != nullptr)
- {
- __clear();
- __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
+ __vec_.__annotate_delete();
+ std::__debug_db_erase_c(std::addressof(__vec_));
+
+ if (__vec_.__begin_ != nullptr) {
+ __vec_.__clear();
+ __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());
+ }
}
- }
- vector(const vector& __x);
- vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ private:
+ vector& __vec_;
+ };
+
+public:
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector& operator=(const vector& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(initializer_list<value_type> __il);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
noexcept;
@@ -458,171 +480,163 @@ public:
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- template <class _InputIterator>
- typename enable_if <__is_exactly_cpp17_input_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);
+ template <class _InputIterator,
+ __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last);
+ template <
+ class _ForwardIterator,
+ __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const_reference __u);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_iterator cbegin() const _NOEXCEPT
{return begin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_iterator cend() const _NOEXCEPT
{return end();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
size_type size() const _NOEXCEPT
{return static_cast<size_type>(this->__end_ - this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
size_type capacity() const _NOEXCEPT
{return static_cast<size_type>(__end_cap() - this->__begin_);}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
value_type* data() _NOEXCEPT
- {return _VSTD::__to_address(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ {return std::__to_address(this->__begin_);}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const value_type* data() const _NOEXCEPT
- {return _VSTD::__to_address(this->__begin_);}
+ {return std::__to_address(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
- _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void pop_back();
- iterator insert(const_iterator __position, const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);
- iterator insert(const_iterator __position, value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
- iterator emplace(const_iterator __position, _Args&&... __args);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
iterator insert(const_iterator __position, size_type __n, const_reference __x);
- template <class _InputIterator>
- typename enable_if <__is_exactly_cpp17_input_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);
+
+ template <class _InputIterator,
+ __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
+ insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+
+ template <
+ class _ForwardIterator,
+ __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
+ insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void clear() _NOEXCEPT
{
size_type __old_size = size();
@@ -631,10 +645,10 @@ public:
std::__debug_db_invalidate_all(this);
}
- void resize(size_type __sz);
- void resize(size_type __sz, const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
@@ -642,7 +656,7 @@ public:
__is_nothrow_swappable<allocator_type>::value);
#endif
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@@ -659,8 +673,7 @@ private:
__compressed_pair<pointer, allocator_type> __end_cap_ =
__compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
- _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
-
+ _LIBCPP_HIDE_FROM_ABI void __invalidate_iterators_past(pointer __new_last);
// Allocate space for __n objects
// throws length_error if __n > max_size()
@@ -669,7 +682,7 @@ private:
// Precondition: __n > 0
// Postcondition: capacity() >= __n
// Postcondition: size() == 0
- _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
if (__n > max_size())
__throw_length_error();
auto __allocation = std::__allocate_at_least(__alloc(), __n);
@@ -679,46 +692,45 @@ private:
__annotate_new(0);
}
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
- void __construct_at_end(size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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(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)
+
+ template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> = 0>
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
+ __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ iterator __make_iter(pointer __p) _NOEXCEPT { return iterator(this, __p); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
+ const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { return const_iterator(this, __p); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- void __move_assign(vector& __c, false_type)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{
- __invalidate_iterators_past(__new_last);
+ if (!__libcpp_is_constant_evaluated())
+ __invalidate_iterators_past(__new_last);
size_type __old_size = size();
__base_destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
inline void __push_back_slow_path(_Up&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
inline void __emplace_back_slow_path(_Args&&... __args);
// The following functions are no-ops outside of AddressSanitizer mode.
@@ -726,39 +738,40 @@ private:
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
#ifndef _LIBCPP_HAS_NO_ASAN
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
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)
+ if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
}
#else
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __annotate_contiguous_container(const void*, const void*, const void*,
const void*) const _NOEXCEPT {}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __annotate_new(size_type __current_size) const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __annotate_delete() const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __annotate_increase(size_type __n) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __annotate_shrink(size_type __old_size) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
@@ -766,13 +779,14 @@ private:
}
struct _ConstructTransaction {
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
__v_.__end_ = __pos_;
#ifndef _LIBCPP_HAS_NO_ASAN
if (__pos_ != __new_end_) {
@@ -791,44 +805,44 @@ private:
};
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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)...);
+ __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_),
+ std::forward<_Args>(__args)...);
++__tx.__pos_;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
allocator_type& __alloc() _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const allocator_type& __alloc() const _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
pointer& __end_cap() _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
const pointer& __end_cap() const _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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));
+ __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
this->__end_ = __new_last;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
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
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__alloc_traits::propagate_on_container_move_assignment::value ||
@@ -838,15 +852,15 @@ private:
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_length_error() const {
- _VSTD::__throw_length_error("vector");
+ std::__throw_length_error("vector");
}
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_out_of_range() const {
- _VSTD::__throw_out_of_range("vector");
+ std::__throw_out_of_range("vector");
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -858,18 +872,18 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __copy_assign_alloc(const vector&, false_type)
{}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
- __alloc() = _VSTD::move(__c.__alloc());
+ __alloc() = std::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
@@ -894,6 +908,7 @@ vector(_InputIterator, _InputIterator, _Alloc)
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
{
@@ -902,15 +917,16 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
__v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
__alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
.base();
- _VSTD::swap(this->__begin_, __v.__begin_);
- _VSTD::swap(this->__end_, __v.__end_);
- _VSTD::swap(this->__end_cap(), __v.__end_cap());
+ std::swap(this->__begin_, __v.__begin_);
+ std::swap(this->__end_, __v.__end_);
+ std::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
std::__debug_db_invalidate_all(this);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<_Tp, _Allocator>::pointer
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
{
@@ -921,9 +937,9 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
__alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
.base();
__v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
- _VSTD::swap(this->__begin_, __v.__begin_);
- _VSTD::swap(this->__end_, __v.__end_);
- _VSTD::swap(this->__end_cap(), __v.__end_cap());
+ std::swap(this->__begin_, __v.__begin_);
+ std::swap(this->__end_, __v.__end_);
+ std::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
std::__debug_db_invalidate_all(this);
@@ -931,6 +947,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
{
@@ -943,16 +960,18 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
- return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),
+ return std::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
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
{
@@ -962,7 +981,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
- return _VSTD::max<size_type>(2 * __cap, __new_size);
+ return std::max<size_type>(2 * __cap, __new_size);
}
// Default constructs __n objects starting at __end_
@@ -971,13 +990,14 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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));
+ __alloc_traits::construct(this->__alloc(), std::__to_address(__pos));
}
}
@@ -988,6 +1008,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
@@ -995,17 +1016,13 @@ 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);
+ __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x);
}
}
template <class _Tp, class _Allocator>
-template <class _ForwardIterator>
-typename enable_if
-<
- __is_cpp17_forward_iterator<_ForwardIterator>::value,
- void
->::type
+template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
_ConstructTransaction __tx(*this, __n);
@@ -1017,6 +1034,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__append(size_type __n)
{
@@ -1036,6 +1054,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
{
@@ -1051,142 +1070,160 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
+ __guard.__complete();
}
#if _LIBCPP_STD_VER > 11
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
+ __guard.__complete();
}
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
-template <class _InputIterator>
-vector<_Tp, _Allocator>::vector(_InputIterator __first,
- typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
- is_constructible<
- value_type,
- typename iterator_traits<_InputIterator>::reference>::value,
- _InputIterator>::type __last)
-{
- _VSTD::__debug_db_insert_c(this);
+template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
+{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
emplace_back(*__first);
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
-template <class _InputIterator>
-vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
- typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
- is_constructible<
- value_type,
- typename iterator_traits<_InputIterator>::reference>::value>::type*)
+template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
emplace_back(*__first);
+ __guard.__complete();
}
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));
+template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
+{
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
+ __guard.__complete();
}
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*)
+template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
- size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
size_type __n = __x.size();
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
size_type __n = __x.size();
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
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()))
+ : __end_cap_(nullptr, std::move(__x.__alloc()))
{
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
std::__debug_db_swap(this, std::addressof(__x));
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
@@ -1195,11 +1232,12 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ std::__debug_db_insert_c(this);
if (__a == __x.__alloc())
{
this->__begin_ = __x.__begin_;
@@ -1211,41 +1249,50 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
else
{
typedef move_iterator<iterator> _Ip;
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
assign(_Ip(__x.begin()), _Ip(__x.end()));
+ __guard.__complete();
}
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
+ __guard.__complete();
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
- _VSTD::__debug_db_insert_c(this);
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ std::__debug_db_insert_c(this);
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
+ __guard.__complete();
}
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -1256,6 +1303,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -1270,6 +1318,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
@@ -1284,11 +1333,12 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(const vector& __x)
{
- if (this != _VSTD::addressof(__x))
+ if (this != std::addressof(__x))
{
__copy_assign_alloc(__x);
assign(__x.__begin_, __x.__end_);
@@ -1297,13 +1347,10 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
}
template <class _Tp, class _Allocator>
-template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
- is_constructible<
- _Tp,
- typename iterator_traits<_InputIterator>::reference>::value,
- void
->::type
+template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
{
clear();
@@ -1312,18 +1359,13 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
}
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
+template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
- size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
+ size_type __new_size = static_cast<size_type>(std::distance(__first, __last));
if (__new_size <= capacity())
{
_ForwardIterator __mid = __last;
@@ -1332,9 +1374,9 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
{
__growing = true;
__mid = __first;
- _VSTD::advance(__mid, size());
+ std::advance(__mid, size());
}
- pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
+ pointer __m = std::copy(__first, __mid, this->__begin_);
if (__growing)
__construct_at_end(__mid, __last, __new_size - size());
else
@@ -1350,13 +1392,14 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ std::fill_n(this->__begin_, std::min(__n, __s), __u);
if (__n > __s)
__construct_at_end(__n - __s, __u);
else
@@ -1372,39 +1415,44 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::begin() _NOEXCEPT
{
- return iterator(this, this->__begin_);
+ return __make_iter(this->__begin_);
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::begin() const _NOEXCEPT
{
- return const_iterator(this, this->__begin_);
+ return __make_iter(this->__begin_);
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::end() _NOEXCEPT
{
- return iterator(this, this->__end_);
+ return __make_iter(this->__end_);
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::end() const _NOEXCEPT
{
- return const_iterator(this, this->__end_);
+ return __make_iter(this->__end_);
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
{
@@ -1413,7 +1461,8 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
{
@@ -1422,6 +1471,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::at(size_type __n)
{
@@ -1431,6 +1481,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::at(size_type __n) const
{
@@ -1440,6 +1491,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -1454,6 +1506,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -1477,19 +1530,21 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
template <class _Tp, class _Allocator>
template <class _Up>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
{
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.push_back(std::forward<_Up>(__x));
+ __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x));
__v.__end_++;
__swap_out_circular_buffer(__v);
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
vector<_Tp, _Allocator>::push_back(const_reference __x)
{
@@ -1502,33 +1557,36 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
vector<_Tp, _Allocator>::push_back(value_type&& __x)
{
if (this->__end_ < this->__end_cap())
{
- __construct_one_at_end(_VSTD::move(__x));
+ __construct_one_at_end(std::move(__x));
}
else
- __push_back_slow_path(_VSTD::move(__x));
+ __push_back_slow_path(std::move(__x));
}
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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.emplace_back(std::forward<_Args>(__args)...);
+ __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);
__v.__end_++;
__swap_out_circular_buffer(__v);
}
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
#if _LIBCPP_STD_VER > 14
typename vector<_Tp, _Allocator>::reference
@@ -1539,16 +1597,17 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (this->__end_ < this->__end_cap())
{
- __construct_one_at_end(_VSTD::forward<_Args>(__args)...);
+ __construct_one_at_end(std::forward<_Args>(__args)...);
}
else
- __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
+ __emplace_back_slow_path(std::forward<_Args>(__args)...);
#if _LIBCPP_STD_VER > 14
return this->back();
#endif
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
inline
void
vector<_Tp, _Allocator>::pop_back()
@@ -1558,42 +1617,45 @@ vector<_Tp, _Allocator>::pop_back()
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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 = iterator(this, __p);
- return __r;
+ this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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);
+ this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
}
- iterator __r = iterator(this, __p);
- return __r;
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
{
@@ -1605,21 +1667,23 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
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));
+ std::__to_address(__pos),
+ std::move(*__i));
}
}
- _VSTD::move_backward(__from_s, __from_s + __n, __old_last);
+ std::move_backward(__from_s, __from_s + __n, __old_last);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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())
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
{
if (__p == this->__end_)
{
@@ -1641,79 +1705,83 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
__v.push_back(__x);
__p = __swap_out_circular_buffer(__v, __p);
}
- return iterator(this, __p);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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));
+ __construct_one_at_end(std::move(__x));
}
else
{
__move_range(__p, this->__end_, __p + 1);
- *__p = _VSTD::move(__x);
+ *__p = std::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));
+ __v.push_back(std::move(__x));
__p = __swap_out_circular_buffer(__v, __p);
}
- return iterator(this, __p);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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)...);
+ __construct_one_at_end(std::forward<_Args>(__args)...);
}
else
{
- __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
+ __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...);
__move_range(__p, this->__end_, __p + 1);
- *__p = _VSTD::move(__tmp.get());
+ *__p = std::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)...);
+ __v.emplace_back(std::forward<_Args>(__args)...);
__p = __swap_out_circular_buffer(__v, __p);
}
- return iterator(this, __p);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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_))
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
{
size_type __old_n = __n;
pointer __old_last = this->__end_;
@@ -1729,7 +1797,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
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);
+ std::fill_n(__p, __n, *__xr);
}
}
else
@@ -1740,20 +1808,17 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
__p = __swap_out_circular_buffer(__v, __p);
}
}
- return iterator(this, __p);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
-template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
- is_constructible<
- _Tp,
- typename iterator_traits<_InputIterator>::reference>::value,
- typename vector<_Tp, _Allocator>::iterator
->::type
+template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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;
@@ -1780,33 +1845,28 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
}
catch (...)
{
- erase(iterator(this, __old_last), end());
+ erase(__make_iter(__old_last), end());
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
- __p = _VSTD::rotate(__p, __old_last, this->__end_);
- insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()),
- _VSTD::make_move_iterator(__v.end()));
+ __p = std::rotate(__p, __old_last, this->__end_);
+ insert(__make_iter(__p), std::make_move_iterator(__v.begin()),
+ std::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
+template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
+ is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
+ int> >
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
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,
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::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);
+ difference_type __n = std::distance(__first, __last);
if (__n > 0)
{
if (__n <= this->__end_cap() - this->__end_)
@@ -1819,14 +1879,14 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
{
__m = __first;
difference_type __diff = this->__end_ - __p;
- _VSTD::advance(__m, __diff);
+ std::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);
+ std::copy(__first, __m, __p);
}
}
else
@@ -1837,10 +1897,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
__p = __swap_out_circular_buffer(__v, __p);
}
}
- return iterator(this, __p);
+ return __make_iter(__p);
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::resize(size_type __sz)
{
@@ -1852,6 +1913,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
{
@@ -1863,6 +1925,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
@@ -1876,15 +1939,16 @@ vector<_Tp, _Allocator>::swap(vector& __x)
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(),
+ std::swap(this->__begin_, __x.__begin_);
+ std::swap(this->__end_, __x.__end_);
+ std::swap(this->__end_cap(), __x.__end_cap());
+ std::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
std::__debug_db_swap(this, std::addressof(__x));
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
bool
vector<_Tp, _Allocator>::__invariants() const
{
@@ -1940,7 +2004,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
#endif // _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@@ -1951,7 +2015,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
if (__i->base() > __new_last) {
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
- _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+ std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
@@ -1987,11 +2051,11 @@ public:
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;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
private:
- typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
+ typedef __rebind_alloc<__alloc_traits, __storage_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;
@@ -2007,81 +2071,99 @@ public:
typedef __bit_const_reference<vector> const_reference;
#endif
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type& __cap() _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const size_type& __cap() const _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
__storage_allocator& __alloc() _NOEXCEPT
{return __cap_alloc_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
{return __n * __bits_per_word;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
{return (__n - 1) / __bits_per_word + 1;}
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
+
+private:
+ class __destroy_vector {
+ public:
+ _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
+ if (__vec_.__begin_ != nullptr)
+ __storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap());
+ std::__debug_db_invalidate_all(this);
+ }
+
+ private:
+ vector& __vec_;
+ };
+
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector(*this)(); }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _ForwardIterator>
- vector(_ForwardIterator __first, _ForwardIterator __last,
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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,
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
@@ -2089,162 +2171,162 @@ public:
typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
- assign(_InputIterator __first, _InputIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
- assign(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const value_type& __x);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(this->__alloc());}
- size_type max_size() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type capacity() const _NOEXCEPT
{return __internal_cap_to_external(__cap());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_type size() const _NOEXCEPT
{return __size_;}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool empty() const _NOEXCEPT
{return __size_ == 0;}
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator begin() _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator begin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator end() _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator end() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator cbegin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_iterator cend() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) {return __make_ref(__n);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {return __make_ref(__n);}
+ _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
+ _LIBCPP_HIDE_FROM_ABI 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);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() {return __make_ref(0);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const {return __make_ref(0);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() {return __make_ref(__size_ - 1);}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const {return __make_ref(__size_ - 1);}
- void push_back(const value_type& __x);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args)
#else
- _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
+ _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)
#endif
{
- push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));
+ push_back ( value_type ( std::forward<_Args>(__args)... ));
#if _LIBCPP_STD_VER > 14
return this->back();
#endif
}
#endif
- _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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)... )); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args)
+ { return insert ( __position, value_type ( std::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);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
template <class _InputIterator>
typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
iterator
>::type
- insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void clear() _NOEXCEPT {__size_ = 0;}
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 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); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { std::swap(__x, __y); }
- void resize(size_type __sz, value_type __x = false);
- void flip() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT;
- bool __invariants() const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
private:
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_length_error() const {
- _VSTD::__throw_length_error("vector");
+ std::__throw_length_error("vector");
}
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_out_of_range() const {
- _VSTD::__throw_out_of_range("vector");
+ std::__throw_out_of_range("vector");
}
// Allocate space for __n objects
@@ -2254,52 +2336,56 @@ private:
// Precondition: __n > 0
// Postcondition: capacity() >= __n
// Postcondition: size() == 0
- _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {
if (__n > max_size())
__throw_length_error();
auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
__begin_ = __allocation.ptr;
__size_ = 0;
__cap() = __allocation.count;
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_type __i = 0; __i != __cap(); ++__i)
+ std::__construct_at(std::__to_address(__begin_) + __i);
+ }
}
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
reference __make_ref(size_type __pos) _NOEXCEPT
{return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
const_reference __make_ref(size_type __pos) const _NOEXCEPT {
return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
__storage_type(1) << __pos % __bits_per_word);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator __make_iter(size_type __pos) _NOEXCEPT
{return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
{return begin() + (__p - cbegin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -2307,33 +2393,33 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __copy_assign_alloc(const vector&, false_type)
{}
- void __move_assign(vector& __c, false_type);
- void __move_assign(vector& __c, true_type)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
- __alloc() = _VSTD::move(__c.__alloc());
+ __alloc() = std::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
- size_t __hash_code() const _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
friend class __bit_const_reference<vector>;
@@ -2344,7 +2430,7 @@ private:
};
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
@@ -2357,6 +2443,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::max_size() const _NOEXCEPT
{
@@ -2369,7 +2456,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
// Precondition: __new_size > capacity()
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::__recommend(size_type __new_size) const
{
@@ -2379,7 +2466,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
- return _VSTD::max(2 * __cap, __align_it(__new_size));
+ return std::max(2 * __cap, __align_it(__new_size));
}
// Default constructs __n objects starting at __end_
@@ -2387,7 +2474,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
{
@@ -2400,11 +2487,12 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
else
this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
}
- _VSTD::fill_n(__make_iter(__old_size), __n, __x);
+ std::fill_n(__make_iter(__old_size), __n, __x);
}
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2413,7 +2501,7 @@ typename enable_if
vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
size_type __old_size = this->__size_;
- this->__size_ += _VSTD::distance(__first, __last);
+ this->__size_ += std::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)
@@ -2421,11 +2509,11 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
else
this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
}
- _VSTD::copy(__first, __last, __make_iter(__old_size));
+ std::copy(__first, __last, __make_iter(__old_size));
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
@@ -2435,7 +2523,7 @@ vector<bool, _Allocator>::vector()
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
@@ -2449,6 +2537,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(size_type __n)
: __begin_(nullptr),
__size_(0),
@@ -2463,6 +2552,7 @@ vector<bool, _Allocator>::vector(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2477,6 +2567,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
#endif
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
: __begin_(nullptr),
__size_(0),
@@ -2490,6 +2581,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2504,6 +2596,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
@@ -2530,6 +2623,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
@@ -2556,39 +2650,46 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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));
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
+ __guard.__complete();
}
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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));
+ auto __guard = std::__make_exception_guard(__destroy_vector(*this));
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
+ __guard.__complete();
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
: __begin_(nullptr),
__size_(0),
@@ -2603,6 +2704,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2619,14 +2721,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
-vector<bool, _Allocator>::~vector()
-{
- if (__begin_ != nullptr)
- __storage_traits::deallocate(__alloc(), __begin_, __cap());
- std::__debug_db_invalidate_all(this);
-}
-
-template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(const vector& __v)
: __begin_(nullptr),
__size_(0),
@@ -2640,6 +2735,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2653,10 +2749,11 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(const vector& __v)
{
- if (this != _VSTD::addressof(__v))
+ if (this != std::addressof(__v))
{
__copy_assign_alloc(__v);
if (__v.__size_)
@@ -2666,7 +2763,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
__vdeallocate();
__vallocate(__v.__size_);
}
- _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
+ std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
}
__size_ = __v.__size_;
}
@@ -2674,7 +2771,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
@@ -2682,13 +2779,14 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
#endif
: __begin_(__v.__begin_),
__size_(__v.__size_),
- __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {
+ __cap_alloc_(std::move(__v.__cap_alloc_)) {
__v.__begin_ = nullptr;
__v.__size_ = 0;
__v.__cap() = 0;
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
: __begin_(nullptr),
__size_(0),
@@ -2710,7 +2808,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -2721,7 +2819,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
{
if (__alloc() != __c.__alloc())
@@ -2731,7 +2829,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
@@ -2745,7 +2843,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
{
__size_ = 0;
@@ -2761,14 +2859,14 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
__v.__size_ = __n;
swap(__v);
}
- _VSTD::fill_n(begin(), __n, __x);
+ std::fill_n(begin(), __n, __x);
}
std::__debug_db_invalidate_all(this);
}
template <class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2780,6 +2878,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2788,7 +2887,7 @@ typename enable_if
vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
clear();
- difference_type __ns = _VSTD::distance(__first, __last);
+ difference_type __ns = std::distance(__first, __last);
_LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
const size_t __n = static_cast<size_type>(__ns);
if (__n)
@@ -2803,7 +2902,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
@@ -2819,7 +2918,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
{
if (__external_cap_to_internal(size()) > __cap())
@@ -2857,7 +2956,7 @@ vector<bool, _Allocator>::at(size_type __n) const
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::push_back(const value_type& __x)
{
if (this->__size_ == this->capacity())
@@ -2867,7 +2966,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
{
iterator __r;
@@ -2875,7 +2974,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
{
const_iterator __old_end = end();
++__size_;
- _VSTD::copy_backward(__position, __old_end, end());
+ std::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
@@ -2883,8 +2982,8 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
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());
+ __r = std::copy(cbegin(), __position, __v.begin());
+ std::copy_backward(__position, cend(), __v.end());
swap(__v);
}
*__r = __x;
@@ -2892,7 +2991,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
{
iterator __r;
@@ -2901,7 +3000,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
{
const_iterator __old_end = end();
__size_ += __n;
- _VSTD::copy_backward(__position, __old_end, end());
+ std::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
@@ -2909,17 +3008,17 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
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());
+ __r = std::copy(cbegin(), __position, __v.begin());
+ std::copy_backward(__position, cend(), __v.end());
swap(__v);
}
- _VSTD::fill_n(__r, __n, __x);
+ std::fill_n(__r, __n, __x);
return __r;
}
template <class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -2954,13 +3053,14 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
- __p = _VSTD::rotate(__p, __old_end, end());
+ __p = std::rotate(__p, __old_end, end());
insert(__p, __v.begin(), __v.end());
return begin() + __off;
}
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2968,7 +3068,7 @@ typename enable_if
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
- const difference_type __n_signed = _VSTD::distance(__first, __last);
+ const difference_type __n_signed = std::distance(__first, __last);
_LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
const size_type __n = static_cast<size_type>(__n_signed);
iterator __r;
@@ -2977,7 +3077,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
{
const_iterator __old_end = end();
__size_ += __n;
- _VSTD::copy_backward(__position, __old_end, end());
+ std::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
@@ -2985,38 +3085,39 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
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());
+ __r = std::copy(cbegin(), __position, __v.begin());
+ std::copy_backward(__position, cend(), __v.end());
swap(__v);
}
- _VSTD::copy(__first, __last, __r);
+ std::copy(__first, __last, __r);
return __r;
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ std::copy(__position + 1, this->cend(), __r);
--__size_;
return __r;
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_SINCE_CXX20
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);
+ std::copy(__last, this->cend(), __r);
__size_ -= __d;
return __r;
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
@@ -3025,15 +3126,15 @@ vector<bool, _Allocator>::swap(vector& __x)
__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(),
+ std::swap(this->__begin_, __x.__begin_);
+ std::swap(this->__size_, __x.__size_);
+ std::swap(this->__cap(), __x.__cap());
+ std::__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
{
size_type __cs = size();
@@ -3052,17 +3153,17 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
vector __v(get_allocator());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
- __r = _VSTD::copy(cbegin(), cend(), __v.begin());
+ __r = std::copy(cbegin(), cend(), __v.begin());
swap(__v);
}
- _VSTD::fill_n(__r, __n, __x);
+ std::fill_n(__r, __n, __x);
}
else
__size_ = __sz;
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void
vector<bool, _Allocator>::flip() _NOEXCEPT
{
// do middle whole words
@@ -3081,7 +3182,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
}
template <class _Allocator>
-bool
+_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
vector<bool, _Allocator>::__invariants() const
{
if (this->__begin_ == nullptr)
@@ -3100,7 +3201,7 @@ vector<bool, _Allocator>::__invariants() const
}
template <class _Allocator>
-size_t
+_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
{
size_t __h = 0;
@@ -3122,22 +3223,24 @@ template <class _Allocator>
struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
: public __unary_function<vector<bool, _Allocator>, size_t>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
{return __vec.__hash_code();}
};
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
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());
+ return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
@@ -3145,15 +3248,17 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
- return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+ return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
@@ -3161,7 +3266,8 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
@@ -3169,7 +3275,8 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
bool
operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
@@ -3177,7 +3284,8 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI
void
swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
@@ -3187,32 +3295,72 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI 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());
+ __c.erase(std::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
+_LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI 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());
+ __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
return __old_size - __c.size();
}
template <>
-inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;
+inline constexpr bool __format::__enable_insertable<vector<char>> = true;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;
+inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
#endif
#endif // _LIBCPP_STD_VER > 17
+#if _LIBCPP_STD_VER > 20
+template <class _Tp, class CharT>
+// Since is-vector-bool-reference is only used once it's inlined here.
+ requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Tp, CharT> {
+private:
+ formatter<bool, CharT> __underlying_;
+
+public:
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return __underlying_.parse(__ctx);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {
+ return __underlying_.format(__ref, __ctx);
+ }
+};
+#endif // _LIBCPP_STD_VER > 20
+
_LIBCPP_END_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace pmr {
+template <class _ValueT>
+using vector = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;
+} // namespace pmr
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <algorithm>
+# include <atomic>
+# include <concepts>
+# include <typeinfo>
+# include <utility>
+#endif
+
#endif // _LIBCPP_VECTOR
diff --git a/libcxx/include/version b/libcxx/include/version
index 1df51fa1cb86..9705229a1c52 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -55,13 +55,16 @@ __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_algorithms 201806L <algorithm> <utility>
+__cpp_lib_constexpr_bitset 202207L <bitset>
+__cpp_lib_constexpr_charconv 202207L <charconv>
__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_memory 202202L <memory>
+ 201811L // C++20
__cpp_lib_constexpr_numeric 201911L <numeric>
__cpp_lib_constexpr_string 201907L <string>
__cpp_lib_constexpr_string_view 201811L <string_view>
@@ -79,8 +82,10 @@ __cpp_lib_erase_if 202002L <deque> <forward
__cpp_lib_exchange_function 201304L <utility>
__cpp_lib_execution 201902L <execution>
201603L // C++17
+__cpp_lib_expected 202202L <expected>
__cpp_lib_filesystem 201703L <filesystem>
__cpp_lib_format 202106L <format>
+__cpp_lib_forward_like 202207L <utility>
__cpp_lib_gcd_lcm 201606L <numeric>
__cpp_lib_generic_associative_lookup 201304L <map> <set>
__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>
@@ -132,7 +137,7 @@ __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>
+__cpp_lib_ranges 202106L <algorithm> <functional> <iterator>
<memory> <ranges>
__cpp_lib_ranges_chunk 202202L <ranges>
__cpp_lib_ranges_chunk_by 202202L <ranges>
@@ -262,7 +267,7 @@ __cpp_lib_void_t 201411L <type_traits>
# 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_memory_resource 201603L
# define __cpp_lib_node_extract 201606L
# define __cpp_lib_nonmember_container_access 201411L
# define __cpp_lib_not_fn 201603L
@@ -312,7 +317,7 @@ __cpp_lib_void_t 201411L <type_traits>
# endif
# define __cpp_lib_concepts 202002L
# define __cpp_lib_constexpr_algorithms 201806L
-// # define __cpp_lib_constexpr_complex 201711L
+# 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
@@ -322,7 +327,7 @@ __cpp_lib_void_t 201411L <type_traits>
# 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_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
@@ -331,7 +336,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_erase_if 202002L
# undef __cpp_lib_execution
// # define __cpp_lib_execution 201902L
-# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
// # define __cpp_lib_format 202106L
# endif
# define __cpp_lib_generic_unordered_lookup 201811L
@@ -350,8 +355,8 @@ __cpp_lib_void_t 201411L <type_traits>
# endif
# define __cpp_lib_list_remove_return_type 201806L
# define __cpp_lib_math_constants 201907L
-// # define __cpp_lib_polymorphic_allocator 201902L
-// # define __cpp_lib_ranges 201811L
+# define __cpp_lib_polymorphic_allocator 201902L
+# define __cpp_lib_ranges 202106L
# 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
@@ -360,7 +365,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_shared_ptr_arrays 201707L
# define __cpp_lib_shift 201806L
// # define __cpp_lib_smart_ptr_for_overwrite 202002L
-// # define __cpp_lib_source_location 201907L
+# if __has_builtin(__builtin_source_location)
+# define __cpp_lib_source_location 201907L
+# endif
# define __cpp_lib_span 202002L
# define __cpp_lib_ssize 201902L
# define __cpp_lib_starts_ends_with 201711L
@@ -380,8 +387,14 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_associative_heterogeneous_erasure 202110L
// # define __cpp_lib_bind_back 202202L
# define __cpp_lib_byteswap 202110L
+# define __cpp_lib_constexpr_bitset 202207L
+# define __cpp_lib_constexpr_charconv 202207L
// # define __cpp_lib_constexpr_cmath 202202L
+# undef __cpp_lib_constexpr_memory
+# define __cpp_lib_constexpr_memory 202202L
// # define __cpp_lib_constexpr_typeinfo 202106L
+# define __cpp_lib_expected 202202L
+# define __cpp_lib_forward_like 202207L
// # define __cpp_lib_invoke_r 202106L
# define __cpp_lib_is_scoped_enum 202011L
// # define __cpp_lib_move_only_function 202110L
diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h
index 0fba53b268ae..c684508dc2cc 100644
--- a/libcxx/include/wchar.h
+++ b/libcxx/include/wchar.h
@@ -120,7 +120,9 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
#endif
-#include_next <wchar.h>
+# if __has_include_next(<wchar.h>)
+# include_next <wchar.h>
+# endif
// Determine whether we have const-correct overloads for wcschr and friends.
#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)