// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_ALGORITHM #define _LIBCPP_ALGORITHM /* algorithm synopsis #include namespace std { namespace ranges { // [algorithms.results], algorithm result types template struct in_fun_result; // since C++20 template struct in_in_result; // since C++20 template struct in_out_result; // since C++20 template struct in_in_out_result; // since C++20 template struct in_out_out_result; // since C++20 template struct min_max_result; // since C++20 template struct in_found_result; // since C++20 template struct in_value_result; // since C++23 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> // since C++20 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); template, Proj>> Comp = ranges::less> // since C++20 constexpr borrowed_iterator_t min_element(R&& r, Comp comp = {}, Proj proj = {}); template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using mismatch_result = in_in_result; template S1, input_iterator I2, sentinel_for<_I2> S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr mismatch_result<_I1, _I2> // since C++20 mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr mismatch_result, borrowed_iterator_t> mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 requires indirect_binary_predicate, const T*> constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20 template requires indirect_binary_predicate, Proj>, const T*> constexpr borrowed_iterator_t find(R&& r, const T& value, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t find_if(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr T min(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr range_value_t min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr T max(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr range_value_t max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using unary_transform_result = in_out_result; // since C++20 template using binary_transform_result = in_in_out_result; // since C++20 template S, weakly_incrementable O, copy_constructible F, class Proj = identity> requires indirectly_writable>> constexpr ranges::unary_transform_result transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20 template requires indirectly_writable, Proj>>> constexpr ranges::unary_transform_result, O> transform(R&& r, O result, F op, Proj proj = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, copy_constructible F, class Proj1 = identity, class Proj2 = identity> requires indirectly_writable, projected>> constexpr ranges::binary_transform_result transform(I1 first1, S1 last1, I2 first2, S2 last2, O result, F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_writable, Proj1>, projected, Proj2>>> constexpr ranges::binary_transform_result, borrowed_iterator_t, O> transform(R1&& r1, R2&& r2, O result, F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class T, class Proj = identity> requires indirect_binary_predicate, const T*> constexpr iter_difference_t count(I first, S last, const T& value, Proj proj = {}); // since C++20 template requires indirect_binary_predicate, Proj>, const T*> constexpr range_difference_t count(R&& r, const T& value, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr iter_difference_t count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr range_difference_t count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 template using minmax_result = min_max_result; template> Comp = ranges::less> constexpr ranges::minmax_result minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr ranges::minmax_result minmax(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr ranges::minmax_result> minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using minmax_element_result = min_max_result; template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr ranges::minmax_element_result minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr ranges::minmax_element_result> minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using copy_result = in_out_result; // since C++20 template using copy_n_result = in_out_result; // since C++20 template using copy_if_result = in_out_result; // since C++20 template using copy_backward_result = in_out_result; // since C++20 template S, class T, class Proj = identity> requires indirect_binary_predicate, const T*> constexpr bool ranges::contains(I first, S last, const T& value, Proj proj = {}); // since C++23 template requires indirect_binary_predicate, Proj>, const T*> constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); // since C++23 template S, weakly_incrementable O> requires indirectly_copyable constexpr ranges::copy_result ranges::copy(I first, S last, O result); // since C++20 template requires indirectly_copyable, O> constexpr ranges::copy_result, O> ranges::copy(R&& r, O result); // since C++20 template requires indirectly_copyable constexpr ranges::copy_n_result ranges::copy_n(I first, iter_difference_t n, O result); // since C++20 template S, weakly_incrementable O, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable constexpr ranges::copy_if_result ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires indirectly_copyable, O> constexpr ranges::copy_if_result, O> ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20 template S1, bidirectional_iterator I2> requires indirectly_copyable constexpr ranges::copy_backward_result ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20 template requires indirectly_copyable, I> constexpr ranges::copy_backward_result, I> ranges::copy_backward(R&& r, I result); // since C++20 template using for_each_result = in_fun_result; // since C++20 template S, class Proj = identity, indirectly_unary_invocable> Fun> constexpr ranges::for_each_result ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20 template, Proj>> Fun> constexpr ranges::for_each_result, Fun> ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20 template> Fun> constexpr ranges::for_each_n_result ranges::for_each_n(I first, iter_difference_t n, Fun f, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S> requires permutable constexpr I ranges::reverse(I first, S last); // since C++20 template requires permutable> constexpr borrowed_iterator_t ranges::reverse(R&& r); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> borrowed_iterator_t ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::partial_sort(R&& r, iterator_t middle, Comp comp = {}, Proj proj = {}); // since C++20 template O, sentinel_for S> constexpr O ranges::fill(O first, S last, const T& value); // since C++20 template R> constexpr borrowed_iterator_t ranges::fill(R&& r, const T& value); // since C++20 template O> constexpr O ranges::fill_n(O first, iter_difference_t n, const T& value); // since C++20 template S, copy_constructible F> requires invocable && indirectly_writable> constexpr O generate(O first, S last, F gen); // since C++20 template void generate(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Generator gen); // since C++17 template requires invocable && output_range> constexpr borrowed_iterator_t generate(R&& r, F gen); // since C++20 template requires invocable && indirectly_writable> constexpr O generate_n(O first, iter_difference_t n, F gen); // since C++20 template ForwardIterator generate_n(ExecutionPolicy&& exec, ForwardIterator first, Size n, Generator gen); // since C++17 template S1, input_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires (forward_iterator || sized_sentinel_for) && (forward_iterator || sized_sentinel_for) && indirectly_comparable constexpr bool ranges::ends_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 template requires (forward_range || sized_range) && (forward_range || sized_range) && indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr bool ranges::ends_with(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr bool ranges::starts_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr bool ranges::starts_with(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 template S1, random_access_iterator I2, sentinel_for S2, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires indirectly_copyable && sortable && indirect_strict_weak_order, projected> constexpr partial_sort_copy_result partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_copyable, iterator_t> && sortable, Comp, Proj2> && indirect_strict_weak_order, Proj1>, projected, Proj2>> constexpr partial_sort_copy_result, borrowed_iterator_t> partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr I ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t ranges::nth_element(R&& r, iterator_t nth, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> // since C++20 constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr I lower_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr bool binary_search(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr bool binary_search(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr subrange partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires permutable> constexpr borrowed_subrange_t partition(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> requires permutable subrange stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires permutable> borrowed_subrange_t stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr borrowed_iterator_t ranges::find_first_of(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Proj = identity, indirect_binary_predicate, projected> Pred = ranges::equal_to> constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C++20 template, Proj>, projected, Proj>> Pred = ranges::equal_to> constexpr borrowed_iterator_t ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20 template S, class T1, class T2, class Proj = identity> requires indirectly_writable && indirect_binary_predicate, const T1*> constexpr I ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 template requires indirectly_writable, const T2&> && indirect_binary_predicate, Proj>, const T1*> constexpr borrowed_iterator_t ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_writable constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20 template, Proj>> Pred> requires indirectly_writable, const T&> constexpr borrowed_iterator_t ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20 template> 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 S1, input_iterator I2, sentinel_for S2, class Proj1 = identity, class Proj2 = identity, indirect_strict_weak_order, projected> Comp = ranges::less> constexpr bool ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template, Proj1>, projected, Proj2>> Comp = ranges::less> constexpr bool ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, bidirectional_iterator I2> requires indirectly_movable constexpr ranges::move_backward_result ranges::move_backward(I1 first, S1 last, I2 result); // since C++20 template requires indirectly_movable, I> constexpr ranges::move_backward_result, I> ranges::move_backward(R&& r, I result); // since C++20 template S, weakly_incrementable O> requires indirectly_movable constexpr ranges::move_result ranges::move(I first, S last, O result); // since C++20 template requires indirectly_movable, O> constexpr ranges::move_result, O> ranges::move(R&& r, O result); // since C++20 template using partition_copy_result = in_out_out_result; // since C++20 template S, weakly_incrementable O1, weakly_incrementable O2, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable && indirectly_copyable constexpr partition_copy_result partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires indirectly_copyable, O1> && indirectly_copyable, O2> constexpr partition_copy_result, O1, O2> partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t partition_point(R&& r, Pred pred, Proj proj = {}); // since C++20 template using merge_result = in_in_out_result; // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr merge_result merge(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires mergeable, iterator_t, O, Comp, Proj1, Proj2> constexpr merge_result, borrowed_iterator_t, O> merge(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class T, class Proj = identity> requires indirect_binary_predicate, const T*> constexpr subrange ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20 template requires permutable> && indirect_binary_predicate, Proj>, const T*> constexpr borrowed_subrange_t ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr subrange ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires permutable> constexpr borrowed_subrange_t ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20 template using set_difference_result = in_out_result; // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr set_difference_result set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires mergeable, iterator_t, O, Comp, Proj1, Proj2> constexpr set_difference_result, O> set_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template using set_intersection_result = in_in_out_result; // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr set_intersection_result set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr set_intersection_result, borrowed_iterator_t, O> set_intersection(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 template S, weakly_incrementable O> requires indirectly_copyable constexpr ranges::reverse_copy_result ranges::reverse_copy(I first, S last, O result); // since C++20 template requires indirectly_copyable, O> constexpr ranges::reverse_copy_result, O> ranges::reverse_copy(R&& r, O result); // since C++20 template S> constexpr subrange rotate(I first, I middle, S last); // since C++20 template requires permutable> constexpr borrowed_subrange_t rotate(R&& r, iterator_t middle); // since C++20 template using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 template S, weakly_incrementable O> requires indirectly_copyable constexpr ranges::rotate_copy_result ranges::rotate_copy(I first, I middle, S last, O result); // since C++20 template requires indirectly_copyable, O> constexpr ranges::rotate_copy_result, O> ranges::rotate_copy(R&& r, iterator_t middle, O result); // since C++20 template S, weakly_incrementable O, class Gen> requires (forward_iterator || random_access_iterator) && indirectly_copyable && uniform_random_bit_generator> O sample(I first, S last, O out, iter_difference_t n, Gen&& g); // since C++20 template requires (forward_range || random_access_iterator) && indirectly_copyable, O> && uniform_random_bit_generator> O sample(R&& r, O out, range_difference_t n, Gen&& g); // since C++20 template S, class Gen> requires permutable && uniform_random_bit_generator> I shuffle(I first, S last, Gen&& g); // since C++20 template requires permutable> && uniform_random_bit_generator> borrowed_iterator_t shuffle(R&& r, Gen&& g); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Proj1 = identity, class Proj2 = identity, indirect_equivalence_relation, projected> 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, Proj1>, projected, Proj2>> Pred = ranges::equal_to> constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr subrange ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr borrowed_subrange_t ranges::search(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class T, class Pred = ranges::equal_to, class Proj = identity> requires indirectly_comparable constexpr subrange ranges::search_n(I first, S last, iter_difference_t count, const T& value, Pred pred = {}, Proj proj = {}); // since C++20 template requires indirectly_comparable, const T*, Pred, Proj> constexpr borrowed_subrange_t ranges::search_n(R&& r, range_difference_t count, const T& value, Pred pred = {}, Proj proj = {}); // since C++20 template S, class T, indirectly-binary-left-foldable F> constexpr auto ranges::fold_left(I first, S last, T init, F f); // since C++23 template> F> constexpr auto fold_left(R&& r, T init, F f); // since C++23 template using fold_left_with_iter_result = in_value_result; // since C++23 template S, class T, indirectly-binary-left-foldable F> constexpr see below fold_left_with_iter(I first, S last, T init, F f); // since C++23 template> F> constexpr see below fold_left_with_iter(R&& r, T init, F f); // since C++23 template S1, forward_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable constexpr subrange ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr borrowed_subrange_t ranges::find_end(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template using set_symmetric_difference_result = in_in_out_result; // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr set_symmetric_difference_result set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires mergeable, iterator_t, O, Comp, Proj1, Proj2> constexpr set_symmetric_difference_result, borrowed_iterator_t, O> set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr subrange equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_subrange_t equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template using set_union_result = in_in_out_result; // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> requires mergeable constexpr set_union_result set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template requires mergeable, iterator_t, O, Comp, Proj1, Proj2> constexpr set_union_result, borrowed_iterator_t, O> set_union(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, class Proj1 = identity, class Proj2 = identity, indirect_strict_weak_order, projected> Comp = ranges::less> constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template, Proj1>, projected, Proj2>> Comp = ranges::less> constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> borrowed_iterator_t inplace_merge(R&& r, iterator_t middle, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_equivalence_relation> C = ranges::equal_to> constexpr subrange unique(I first, S last, C comp = {}, Proj proj = {}); // since C++20 template, Proj>> C = ranges::equal_to> requires permutable> constexpr borrowed_subrange_t unique(R&& r, C comp = {}, Proj proj = {}); // since C++20 template S, weakly_incrementable O, class Proj = identity, indirect_equivalence_relation> C = ranges::equal_to> requires indirectly_copyable && (forward_iterator || (input_iterator && same_as, iter_value_t>) || indirectly_copyable_storable) constexpr unique_copy_result unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // since C++20 template, Proj>> C = ranges::equal_to> requires indirectly_copyable, O> && (forward_iterator> || (input_iterator && same_as, iter_value_t>) || indirectly_copyable_storable, O>) constexpr unique_copy_result, O> unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // since C++20 template using remove_copy_result = in_out_result; // since C++20 template S, weakly_incrementable O, class T, class Proj = identity> indirect_binary_predicate, const T*> constexpr remove_copy_result remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // since C++20 template requires indirectly_copyable, O> && indirect_binary_predicate, Proj>, const T*> constexpr remove_copy_result, O> remove_copy(R&& r, O result, const T& value, Proj proj = {}); // since C++20 template using remove_copy_if_result = in_out_result; // since C++20 template S, weakly_incrementable O, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable constexpr remove_copy_if_result remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires indirectly_copyable, O> constexpr remove_copy_if_result, O> remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20 template using replace_copy_result = in_out_result; // since C++20 template S, class T1, class T2, output_iterator O, class Proj = identity> requires indirectly_copyable && indirect_binary_predicate, const T1*> constexpr replace_copy_result replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 template O, class Proj = identity> requires indirectly_copyable, O> && indirect_binary_predicate, Proj>, const T1*> constexpr replace_copy_result, O> replace_copy(R&& r, O result, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 template using replace_copy_if_result = in_out_result; // since C++20 template S, class T, output_iterator O, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable constexpr replace_copy_if_result replace_copy_if(I first, S last, O result, Pred pred, const T& new_value, Proj proj = {}); // since C++20 template O, class Proj = identity, indirect_unary_predicate, Proj>> Pred> requires indirectly_copyable, O> constexpr replace_copy_if_result, O> replace_copy_if(R&& r, O result, Pred pred, const T& new_value, Proj proj = {}); // since C++20 template using prev_permutation_result = in_found_result; // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr ranges::prev_permutation_result ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr ranges::prev_permutation_result> ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using next_permutation_result = in_found_result; // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr ranges::next_permutation_result ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr ranges::next_permutation_result> ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 } template constexpr bool // constexpr in C++20 all_of(InputIterator first, InputIterator last, Predicate pred); template constexpr bool // constexpr in C++20 any_of(InputIterator first, InputIterator last, Predicate pred); template constexpr bool // constexpr in C++20 none_of(InputIterator first, InputIterator last, Predicate pred); template constexpr Function // constexpr in C++20 for_each(InputIterator first, InputIterator last, Function f); template constexpr InputIterator // constexpr in C++20 for_each_n(InputIterator first, Size n, Function f); // C++17 template constexpr InputIterator // constexpr in C++20 find(InputIterator first, InputIterator last, const T& value); template constexpr InputIterator // constexpr in C++20 find_if(InputIterator first, InputIterator last, Predicate pred); template constexpr InputIterator // constexpr in C++20 find_if_not(InputIterator first, InputIterator last, Predicate pred); template constexpr ForwardIterator1 // constexpr in C++20 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template constexpr ForwardIterator1 // constexpr in C++20 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template constexpr ForwardIterator1 // constexpr in C++20 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template constexpr ForwardIterator1 // constexpr in C++20 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template constexpr ForwardIterator // constexpr in C++20 adjacent_find(ForwardIterator first, ForwardIterator last); template constexpr ForwardIterator // constexpr in C++20 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); template constexpr typename iterator_traits::difference_type // constexpr in C++20 count(InputIterator first, InputIterator last, const T& value); template constexpr typename iterator_traits::difference_type // constexpr in C++20 count_if(InputIterator first, InputIterator last, Predicate pred); template constexpr pair // constexpr in C++20 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template constexpr pair // constexpr in C++20 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); // **C++14** template constexpr pair // constexpr in C++20 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); template constexpr pair // constexpr in C++20 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred); // **C++14** template constexpr bool // constexpr in C++20 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template constexpr bool // constexpr in C++20 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); // **C++14** template constexpr bool // constexpr in C++20 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); template constexpr bool // constexpr in C++20 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred); // **C++14** template constexpr bool // constexpr in C++20 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); template constexpr bool // constexpr in C++20 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); // **C++14** template constexpr bool // constexpr in C++20 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred); template constexpr bool // constexpr in C++20 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); // **C++14** template constexpr ForwardIterator1 // constexpr in C++20 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template constexpr ForwardIterator1 // constexpr in C++20 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template constexpr ForwardIterator // constexpr in C++20 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); template constexpr ForwardIterator // constexpr in C++20 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred); template constexpr OutputIterator // constexpr in C++20 copy(InputIterator first, InputIterator last, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); template constexpr OutputIterator // constexpr in C++20 copy_n(InputIterator first, Size n, OutputIterator result); template constexpr BidirectionalIterator2 // constexpr in C++20 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); // [alg.move], move template constexpr OutputIterator move(InputIterator first, InputIterator last, OutputIterator result); template constexpr BidirectionalIterator2 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); template constexpr ForwardIterator2 // constexpr in C++20 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); namespace ranges { template using swap_ranges_result = in_in_result; template S1, input_iterator I2, sentinel_for S2> requires indirectly_swappable constexpr ranges::swap_ranges_result swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); template requires indirectly_swappable, iterator_t> constexpr ranges::swap_ranges_result, borrowed_iterator_t> swap_ranges(R1&& r1, R2&& r2); } template constexpr void // constexpr in C++20 iter_swap(ForwardIterator1 a, ForwardIterator2 b); template constexpr OutputIterator // constexpr in C++20 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); template constexpr OutputIterator // constexpr in C++20 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation binary_op); template constexpr void // constexpr in C++20 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value); template constexpr void // constexpr in C++20 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); template constexpr OutputIterator // constexpr in C++20 replace_copy(InputIterator first, InputIterator last, OutputIterator result, const T& old_value, const T& new_value); template constexpr OutputIterator // constexpr in C++20 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value); template constexpr void // constexpr in C++20 fill(ForwardIterator first, ForwardIterator last, const T& value); template constexpr OutputIterator // constexpr in C++20 fill_n(OutputIterator first, Size n, const T& value); template constexpr void // constexpr in C++20 generate(ForwardIterator first, ForwardIterator last, Generator gen); template constexpr OutputIterator // constexpr in C++20 generate_n(OutputIterator first, Size n, Generator gen); template constexpr ForwardIterator // constexpr in C++20 remove(ForwardIterator first, ForwardIterator last, const T& value); template constexpr ForwardIterator // constexpr in C++20 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred); template constexpr OutputIterator // constexpr in C++20 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); template constexpr OutputIterator // constexpr in C++20 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); template constexpr ForwardIterator // constexpr in C++20 unique(ForwardIterator first, ForwardIterator last); template constexpr ForwardIterator // constexpr in C++20 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); template constexpr OutputIterator // constexpr in C++20 unique_copy(InputIterator first, InputIterator last, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); template constexpr void // constexpr in C++20 reverse(BidirectionalIterator first, BidirectionalIterator last); template constexpr OutputIterator // constexpr in C++20 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); template constexpr ForwardIterator // constexpr in C++20 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last); template constexpr OutputIterator // constexpr in C++20 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); template void random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17 template void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17 template SampleIterator sample(PopulationIterator first, PopulationIterator last, SampleIterator out, Distance n, UniformRandomBitGenerator&& g); // C++17 template void shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); template constexpr ForwardIterator shift_left(ForwardIterator first, ForwardIterator last, typename iterator_traits::difference_type n); // C++20 template constexpr ForwardIterator shift_right(ForwardIterator first, ForwardIterator last, typename iterator_traits::difference_type n); // C++20 template constexpr bool // constexpr in C++20 is_partitioned(InputIterator first, InputIterator last, Predicate pred); template constexpr ForwardIterator // constexpr in C++20 partition(ForwardIterator first, ForwardIterator last, Predicate pred); template constexpr pair // constexpr in C++20 partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); template ForwardIterator stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred); template constexpr ForwardIterator // constexpr in C++20 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); template constexpr bool // constexpr in C++20 is_sorted(ForwardIterator first, ForwardIterator last); template constexpr bool // constexpr in C++20 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); template constexpr ForwardIterator // constexpr in C++20 is_sorted_until(ForwardIterator first, ForwardIterator last); template constexpr ForwardIterator // constexpr in C++20 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp); template constexpr void // constexpr in C++20 sort(RandomAccessIterator first, RandomAccessIterator last); template constexpr void // constexpr in C++20 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void stable_sort(RandomAccessIterator first, RandomAccessIterator last); template void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template constexpr void // constexpr in C++20 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); template constexpr void // constexpr in C++20 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); template constexpr RandomAccessIterator // constexpr in C++20 partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last); template constexpr RandomAccessIterator // constexpr in C++20 partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); template constexpr void // constexpr in C++20 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); template constexpr void // constexpr in C++20 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); template constexpr ForwardIterator // constexpr in C++20 lower_bound(ForwardIterator first, ForwardIterator last, const T& value); template constexpr ForwardIterator // constexpr in C++20 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template constexpr ForwardIterator // constexpr in C++20 upper_bound(ForwardIterator first, ForwardIterator last, const T& value); template constexpr ForwardIterator // constexpr in C++20 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template constexpr pair // constexpr in C++20 equal_range(ForwardIterator first, ForwardIterator last, const T& value); template constexpr pair // constexpr in C++20 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template constexpr bool // constexpr in C++20 binary_search(ForwardIterator first, ForwardIterator last, const T& value); template constexpr bool // constexpr in C++20 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template constexpr OutputIterator // constexpr in C++20 merge(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 merge(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); template void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp); template constexpr bool // constexpr in C++20 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); template constexpr bool // constexpr in C++20 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); template constexpr OutputIterator // constexpr in C++20 set_union(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 set_union(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template constexpr OutputIterator // constexpr in C++20 set_intersection(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 set_intersection(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template constexpr OutputIterator // constexpr in C++20 set_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 set_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template constexpr OutputIterator // constexpr in C++20 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template constexpr OutputIterator // constexpr in C++20 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template constexpr void // constexpr in C++20 push_heap(RandomAccessIterator first, RandomAccessIterator last); template constexpr void // constexpr in C++20 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template constexpr void // constexpr in C++20 pop_heap(RandomAccessIterator first, RandomAccessIterator last); template constexpr void // constexpr in C++20 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template constexpr void // constexpr in C++20 make_heap(RandomAccessIterator first, RandomAccessIterator last); template constexpr void // constexpr in C++20 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template constexpr void // constexpr in C++20 sort_heap(RandomAccessIterator first, RandomAccessIterator last); template constexpr void // constexpr in C++20 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template constexpr bool // constexpr in C++20 is_heap(RandomAccessIterator first, RandomAccessiterator last); template constexpr bool // constexpr in C++20 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp); template constexpr RandomAccessIterator // constexpr in C++20 is_heap_until(RandomAccessIterator first, RandomAccessiterator last); template constexpr RandomAccessIterator // constexpr in C++20 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp); template constexpr ForwardIterator // constexpr in C++14 min_element(ForwardIterator first, ForwardIterator last); template constexpr ForwardIterator // constexpr in C++14 min_element(ForwardIterator first, ForwardIterator last, Compare comp); template constexpr const T& // constexpr in C++14 min(const T& a, const T& b); template constexpr const T& // constexpr in C++14 min(const T& a, const T& b, Compare comp); template constexpr T // constexpr in C++14 min(initializer_list t); template constexpr T // constexpr in C++14 min(initializer_list t, Compare comp); template constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17 template constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17 template constexpr ForwardIterator // constexpr in C++14 max_element(ForwardIterator first, ForwardIterator last); template constexpr ForwardIterator // constexpr in C++14 max_element(ForwardIterator first, ForwardIterator last, Compare comp); template constexpr const T& // constexpr in C++14 max(const T& a, const T& b); template constexpr const T& // constexpr in C++14 max(const T& a, const T& b, Compare comp); template constexpr T // constexpr in C++14 max(initializer_list t); template constexpr T // constexpr in C++14 max(initializer_list t, Compare comp); template constexpr pair // constexpr in C++14 minmax_element(ForwardIterator first, ForwardIterator last); template constexpr pair // constexpr in C++14 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); template constexpr pair // constexpr in C++14 minmax(const T& a, const T& b); template constexpr pair // constexpr in C++14 minmax(const T& a, const T& b, Compare comp); template constexpr pair // constexpr in C++14 minmax(initializer_list t); template constexpr pair // constexpr in C++14 minmax(initializer_list t, Compare comp); template constexpr bool // constexpr in C++20 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); template constexpr bool // constexpr in C++20 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); template constexpr auto lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Cmp comp) -> decltype(comp(*b1, *b2)); // since C++20 template constexpr auto lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); // since C++20 template constexpr bool // constexpr in C++20 next_permutation(BidirectionalIterator first, BidirectionalIterator last); template constexpr bool // constexpr in C++20 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); template constexpr bool // constexpr in C++20 prev_permutation(BidirectionalIterator first, BidirectionalIterator last); template constexpr bool // constexpr in C++20 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); } // std */ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> #include #include <__algorithm/adjacent_find.h> #include <__algorithm/all_of.h> #include <__algorithm/any_of.h> #include <__algorithm/binary_search.h> #include <__algorithm/clamp.h> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> #include <__algorithm/copy_backward.h> #include <__algorithm/copy_if.h> #include <__algorithm/copy_n.h> #include <__algorithm/count.h> #include <__algorithm/count_if.h> #include <__algorithm/equal.h> #include <__algorithm/equal_range.h> #include <__algorithm/fill.h> #include <__algorithm/fill_n.h> #include <__algorithm/find.h> #include <__algorithm/find_end.h> #include <__algorithm/find_first_of.h> #include <__algorithm/find_if.h> #include <__algorithm/find_if_not.h> #include <__algorithm/fold.h> #include <__algorithm/for_each.h> #include <__algorithm/for_each_n.h> #include <__algorithm/generate.h> #include <__algorithm/generate_n.h> #include <__algorithm/half_positive.h> #include <__algorithm/in_found_result.h> #include <__algorithm/in_fun_result.h> #include <__algorithm/in_in_out_result.h> #include <__algorithm/in_in_result.h> #include <__algorithm/in_out_out_result.h> #include <__algorithm/in_out_result.h> #include <__algorithm/includes.h> #include <__algorithm/inplace_merge.h> #include <__algorithm/is_heap.h> #include <__algorithm/is_heap_until.h> #include <__algorithm/is_partitioned.h> #include <__algorithm/is_permutation.h> #include <__algorithm/is_sorted.h> #include <__algorithm/is_sorted_until.h> #include <__algorithm/iter_swap.h> #include <__algorithm/lexicographical_compare.h> #include <__algorithm/lexicographical_compare_three_way.h> #include <__algorithm/lower_bound.h> #include <__algorithm/make_heap.h> #include <__algorithm/max.h> #include <__algorithm/max_element.h> #include <__algorithm/merge.h> #include <__algorithm/min.h> #include <__algorithm/min_element.h> #include <__algorithm/min_max_result.h> #include <__algorithm/minmax.h> #include <__algorithm/minmax_element.h> #include <__algorithm/mismatch.h> #include <__algorithm/move.h> #include <__algorithm/move_backward.h> #include <__algorithm/next_permutation.h> #include <__algorithm/none_of.h> #include <__algorithm/nth_element.h> #include <__algorithm/partial_sort.h> #include <__algorithm/partial_sort_copy.h> #include <__algorithm/partition.h> #include <__algorithm/partition_copy.h> #include <__algorithm/partition_point.h> #include <__algorithm/pop_heap.h> #include <__algorithm/prev_permutation.h> #include <__algorithm/pstl_any_all_none_of.h> #include <__algorithm/pstl_copy.h> #include <__algorithm/pstl_count.h> #include <__algorithm/pstl_equal.h> #include <__algorithm/pstl_fill.h> #include <__algorithm/pstl_find.h> #include <__algorithm/pstl_for_each.h> #include <__algorithm/pstl_generate.h> #include <__algorithm/pstl_is_partitioned.h> #include <__algorithm/pstl_merge.h> #include <__algorithm/pstl_move.h> #include <__algorithm/pstl_replace.h> #include <__algorithm/pstl_rotate_copy.h> #include <__algorithm/pstl_sort.h> #include <__algorithm/pstl_stable_sort.h> #include <__algorithm/pstl_transform.h> #include <__algorithm/push_heap.h> #include <__algorithm/ranges_adjacent_find.h> #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_contains.h> #include <__algorithm/ranges_copy.h> #include <__algorithm/ranges_copy_backward.h> #include <__algorithm/ranges_copy_if.h> #include <__algorithm/ranges_copy_n.h> #include <__algorithm/ranges_count.h> #include <__algorithm/ranges_count_if.h> #include <__algorithm/ranges_ends_with.h> #include <__algorithm/ranges_equal.h> #include <__algorithm/ranges_equal_range.h> #include <__algorithm/ranges_fill.h> #include <__algorithm/ranges_fill_n.h> #include <__algorithm/ranges_find.h> #include <__algorithm/ranges_find_end.h> #include <__algorithm/ranges_find_first_of.h> #include <__algorithm/ranges_find_if.h> #include <__algorithm/ranges_find_if_not.h> #include <__algorithm/ranges_for_each.h> #include <__algorithm/ranges_for_each_n.h> #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> #include <__algorithm/ranges_lower_bound.h> #include <__algorithm/ranges_make_heap.h> #include <__algorithm/ranges_max.h> #include <__algorithm/ranges_max_element.h> #include <__algorithm/ranges_merge.h> #include <__algorithm/ranges_min.h> #include <__algorithm/ranges_min_element.h> #include <__algorithm/ranges_minmax.h> #include <__algorithm/ranges_minmax_element.h> #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> #include <__algorithm/ranges_set_intersection.h> #include <__algorithm/ranges_set_symmetric_difference.h> #include <__algorithm/ranges_set_union.h> #include <__algorithm/ranges_shuffle.h> #include <__algorithm/ranges_sort.h> #include <__algorithm/ranges_sort_heap.h> #include <__algorithm/ranges_stable_partition.h> #include <__algorithm/ranges_stable_sort.h> #include <__algorithm/ranges_starts_with.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> #include <__algorithm/remove_copy_if.h> #include <__algorithm/remove_if.h> #include <__algorithm/replace.h> #include <__algorithm/replace_copy.h> #include <__algorithm/replace_copy_if.h> #include <__algorithm/replace_if.h> #include <__algorithm/reverse.h> #include <__algorithm/reverse_copy.h> #include <__algorithm/rotate.h> #include <__algorithm/rotate_copy.h> #include <__algorithm/sample.h> #include <__algorithm/search.h> #include <__algorithm/search_n.h> #include <__algorithm/set_difference.h> #include <__algorithm/set_intersection.h> #include <__algorithm/set_symmetric_difference.h> #include <__algorithm/set_union.h> #include <__algorithm/shift_left.h> #include <__algorithm/shift_right.h> #include <__algorithm/shuffle.h> #include <__algorithm/sift_down.h> #include <__algorithm/sort.h> #include <__algorithm/sort_heap.h> #include <__algorithm/stable_partition.h> #include <__algorithm/stable_sort.h> #include <__algorithm/swap_ranges.h> #include <__algorithm/transform.h> #include <__algorithm/unique.h> #include <__algorithm/unique_copy.h> #include <__algorithm/unwrap_iter.h> #include <__algorithm/upper_bound.h> // standard-mandated includes // [algorithm.syn] #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include # include # include # include # include # include # include # include # include # include #endif #endif // _LIBCPP_ALGORITHM