From d10dc5a06fac4dcabf2264c64c8672c6f6ae36fb Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Thu, 1 Aug 2024 05:54:06 -0700 Subject: [PATCH] [libc++] Remove dedicated namespaces for ranges functions (#76543) We originally put implementation-detail function objects into individual namespaces for `std::ranges` without a good reason for doing so. This practice was continued, presumably because there was prior art. Since there's no reason to keep these namespaces, this commit removes them, which will slightly impact binary size. This commit does not apply to CPOs, some of which need additional work. --- .../__algorithm/ranges_adjacent_find.h | 6 +- libcxx/include/__algorithm/ranges_all_of.h | 6 +- libcxx/include/__algorithm/ranges_any_of.h | 6 +- .../__algorithm/ranges_binary_search.h | 6 +- libcxx/include/__algorithm/ranges_clamp.h | 6 +- libcxx/include/__algorithm/ranges_contains.h | 6 +- .../__algorithm/ranges_contains_subrange.h | 6 +- libcxx/include/__algorithm/ranges_copy.h | 6 +- .../__algorithm/ranges_copy_backward.h | 6 +- libcxx/include/__algorithm/ranges_copy_if.h | 6 +- libcxx/include/__algorithm/ranges_copy_n.h | 6 +- libcxx/include/__algorithm/ranges_count.h | 6 +- libcxx/include/__algorithm/ranges_count_if.h | 6 +- libcxx/include/__algorithm/ranges_ends_with.h | 6 +- libcxx/include/__algorithm/ranges_equal.h | 6 +- .../include/__algorithm/ranges_equal_range.h | 8 +- libcxx/include/__algorithm/ranges_fill.h | 6 +- libcxx/include/__algorithm/ranges_fill_n.h | 6 +- libcxx/include/__algorithm/ranges_find.h | 6 +- libcxx/include/__algorithm/ranges_find_end.h | 6 +- .../__algorithm/ranges_find_first_of.h | 6 +- libcxx/include/__algorithm/ranges_find_if.h | 6 +- .../include/__algorithm/ranges_find_if_not.h | 6 +- libcxx/include/__algorithm/ranges_find_last.h | 18 ++--- libcxx/include/__algorithm/ranges_for_each.h | 6 +- .../include/__algorithm/ranges_for_each_n.h | 6 +- libcxx/include/__algorithm/ranges_generate.h | 8 +- .../include/__algorithm/ranges_generate_n.h | 8 +- libcxx/include/__algorithm/ranges_includes.h | 8 +- .../__algorithm/ranges_inplace_merge.h | 8 +- libcxx/include/__algorithm/ranges_is_heap.h | 8 +- .../__algorithm/ranges_is_heap_until.h | 8 +- .../__algorithm/ranges_is_partitioned.h | 6 +- .../__algorithm/ranges_is_permutation.h | 6 +- libcxx/include/__algorithm/ranges_is_sorted.h | 6 +- .../__algorithm/ranges_is_sorted_until.h | 6 +- .../ranges_lexicographical_compare.h | 6 +- .../include/__algorithm/ranges_lower_bound.h | 6 +- libcxx/include/__algorithm/ranges_make_heap.h | 8 +- libcxx/include/__algorithm/ranges_max.h | 6 +- .../include/__algorithm/ranges_max_element.h | 6 +- libcxx/include/__algorithm/ranges_merge.h | 74 ++++++++--------- libcxx/include/__algorithm/ranges_min.h | 6 +- .../include/__algorithm/ranges_min_element.h | 6 +- libcxx/include/__algorithm/ranges_minmax.h | 6 +- .../__algorithm/ranges_minmax_element.h | 6 +- libcxx/include/__algorithm/ranges_mismatch.h | 6 +- libcxx/include/__algorithm/ranges_move.h | 6 +- .../__algorithm/ranges_move_backward.h | 6 +- .../__algorithm/ranges_next_permutation.h | 8 +- libcxx/include/__algorithm/ranges_none_of.h | 6 +- .../include/__algorithm/ranges_nth_element.h | 8 +- .../include/__algorithm/ranges_partial_sort.h | 8 +- .../__algorithm/ranges_partial_sort_copy.h | 8 +- libcxx/include/__algorithm/ranges_partition.h | 8 +- .../__algorithm/ranges_partition_copy.h | 8 +- .../__algorithm/ranges_partition_point.h | 8 +- libcxx/include/__algorithm/ranges_pop_heap.h | 8 +- .../__algorithm/ranges_prev_permutation.h | 8 +- libcxx/include/__algorithm/ranges_push_heap.h | 8 +- libcxx/include/__algorithm/ranges_remove.h | 6 +- .../include/__algorithm/ranges_remove_copy.h | 8 +- .../__algorithm/ranges_remove_copy_if.h | 8 +- libcxx/include/__algorithm/ranges_remove_if.h | 6 +- libcxx/include/__algorithm/ranges_replace.h | 6 +- .../include/__algorithm/ranges_replace_copy.h | 8 +- .../__algorithm/ranges_replace_copy_if.h | 8 +- .../include/__algorithm/ranges_replace_if.h | 6 +- libcxx/include/__algorithm/ranges_reverse.h | 6 +- .../include/__algorithm/ranges_reverse_copy.h | 6 +- libcxx/include/__algorithm/ranges_rotate.h | 8 +- .../include/__algorithm/ranges_rotate_copy.h | 6 +- libcxx/include/__algorithm/ranges_sample.h | 8 +- libcxx/include/__algorithm/ranges_search.h | 6 +- libcxx/include/__algorithm/ranges_search_n.h | 6 +- .../__algorithm/ranges_set_difference.h | 8 +- .../__algorithm/ranges_set_intersection.h | 8 +- .../ranges_set_symmetric_difference.h | 8 +- libcxx/include/__algorithm/ranges_set_union.h | 8 +- libcxx/include/__algorithm/ranges_shuffle.h | 8 +- libcxx/include/__algorithm/ranges_sort.h | 8 +- libcxx/include/__algorithm/ranges_sort_heap.h | 8 +- .../__algorithm/ranges_stable_partition.h | 8 +- .../include/__algorithm/ranges_stable_sort.h | 8 +- .../include/__algorithm/ranges_starts_with.h | 10 +-- .../include/__algorithm/ranges_swap_ranges.h | 6 +- libcxx/include/__algorithm/ranges_transform.h | 6 +- libcxx/include/__algorithm/ranges_unique.h | 8 +- .../include/__algorithm/ranges_unique_copy.h | 8 +- .../include/__algorithm/ranges_upper_bound.h | 6 +- libcxx/include/__iterator/advance.h | 8 +- libcxx/include/__iterator/distance.h | 8 +- libcxx/include/__iterator/next.h | 8 +- libcxx/include/__iterator/prev.h | 8 +- libcxx/include/__memory/ranges_construct_at.h | 32 ++------ .../ranges_uninitialized_algorithms.h | 80 +++++-------------- 96 files changed, 255 insertions(+), 583 deletions(-) diff --git a/libcxx/include/__algorithm/ranges_adjacent_find.h b/libcxx/include/__algorithm/ranges_adjacent_find.h index 3c54f723310a..0f2cb6669937 100644 --- a/libcxx/include/__algorithm/ranges_adjacent_find.h +++ b/libcxx/include/__algorithm/ranges_adjacent_find.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __adjacent_find { -struct __fn { +struct __adjacent_find { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -67,10 +66,9 @@ struct __fn { return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __adjacent_find inline namespace __cpo { -inline constexpr auto adjacent_find = __adjacent_find::__fn{}; +inline constexpr auto adjacent_find = __adjacent_find{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_all_of.h b/libcxx/include/__algorithm/ranges_all_of.h index 2f603b32f32d..fea089493811 100644 --- a/libcxx/include/__algorithm/ranges_all_of.h +++ b/libcxx/include/__algorithm/ranges_all_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __all_of { -struct __fn { +struct __all_of { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { for (; __first != __last; ++__first) { @@ -58,10 +57,9 @@ struct __fn { return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __all_of inline namespace __cpo { -inline constexpr auto all_of = __all_of::__fn{}; +inline constexpr auto all_of = __all_of{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_any_of.h b/libcxx/include/__algorithm/ranges_any_of.h index 205fcecc086e..34d23b4b7455 100644 --- a/libcxx/include/__algorithm/ranges_any_of.h +++ b/libcxx/include/__algorithm/ranges_any_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __any_of { -struct __fn { +struct __any_of { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { for (; __first != __last; ++__first) { @@ -58,10 +57,9 @@ struct __fn { return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __any_of inline namespace __cpo { -inline constexpr auto any_of = __any_of::__fn{}; +inline constexpr auto any_of = __any_of{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_binary_search.h b/libcxx/include/__algorithm/ranges_binary_search.h index 1ef2bd62b599..47bd0997334e 100644 --- a/libcxx/include/__algorithm/ranges_binary_search.h +++ b/libcxx/include/__algorithm/ranges_binary_search.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __binary_search { -struct __fn { +struct __binary_search { template _Sent, class _Type, @@ -57,10 +56,9 @@ struct __fn { return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret)); } }; -} // namespace __binary_search inline namespace __cpo { -inline constexpr auto binary_search = __binary_search::__fn{}; +inline constexpr auto binary_search = __binary_search{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_clamp.h b/libcxx/include/__algorithm/ranges_clamp.h index e6181ef9435e..4bb3e46e73bd 100644 --- a/libcxx/include/__algorithm/ranges_clamp.h +++ b/libcxx/include/__algorithm/ranges_clamp.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __clamp { -struct __fn { +struct __clamp { template > _Comp = ranges::less> @@ -50,10 +49,9 @@ struct __fn { return __value; } }; -} // namespace __clamp inline namespace __cpo { -inline constexpr auto clamp = __clamp::__fn{}; +inline constexpr auto clamp = __clamp{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_contains.h b/libcxx/include/__algorithm/ranges_contains.h index 4836c3baed17..88de215297e5 100644 --- a/libcxx/include/__algorithm/ranges_contains.h +++ b/libcxx/include/__algorithm/ranges_contains.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __contains { -struct __fn { +struct __contains { template _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static @@ -50,10 +49,9 @@ struct __fn { ranges::end(__range); } }; -} // namespace __contains inline namespace __cpo { -inline constexpr auto contains = __contains::__fn{}; +inline constexpr auto contains = __contains{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h index 4398c457fd05..e8740d69dbef 100644 --- a/libcxx/include/__algorithm/ranges_contains_subrange.h +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __contains_subrange { -struct __fn { +struct __contains_subrange { template _Sent1, forward_iterator _Iter2, @@ -81,10 +80,9 @@ struct __fn { return __ret.empty() == false; } }; -} // namespace __contains_subrange inline namespace __cpo { -inline constexpr auto contains_subrange = __contains_subrange::__fn{}; +inline constexpr auto contains_subrange = __contains_subrange{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_copy.h b/libcxx/include/__algorithm/ranges_copy.h index e1d6d32f05f7..05b61c0d5d4a 100644 --- a/libcxx/include/__algorithm/ranges_copy.h +++ b/libcxx/include/__algorithm/ranges_copy.h @@ -37,8 +37,7 @@ namespace ranges { template using copy_result = in_out_result<_InIter, _OutIter>; -namespace __copy { -struct __fn { +struct __copy { template _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter> @@ -55,10 +54,9 @@ struct __fn { return {std::move(__ret.first), std::move(__ret.second)}; } }; -} // namespace __copy inline namespace __cpo { -inline constexpr auto copy = __copy::__fn{}; +inline constexpr auto copy = __copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_copy_backward.h b/libcxx/include/__algorithm/ranges_copy_backward.h index 93e326042503..81d14e465f7f 100644 --- a/libcxx/include/__algorithm/ranges_copy_backward.h +++ b/libcxx/include/__algorithm/ranges_copy_backward.h @@ -35,8 +35,7 @@ namespace ranges { template using copy_backward_result = in_out_result<_Ip, _Op>; -namespace __copy_backward { -struct __fn { +struct __copy_backward { template _Sent1, bidirectional_iterator _InIter2> requires indirectly_copyable<_InIter1, _InIter2> _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2> @@ -53,10 +52,9 @@ struct __fn { return {std::move(__ret.first), std::move(__ret.second)}; } }; -} // namespace __copy_backward inline namespace __cpo { -inline constexpr auto copy_backward = __copy_backward::__fn{}; +inline constexpr auto copy_backward = __copy_backward{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_copy_if.h b/libcxx/include/__algorithm/ranges_copy_if.h index 4b41d2154e7f..1a08985fe35c 100644 --- a/libcxx/include/__algorithm/ranges_copy_if.h +++ b/libcxx/include/__algorithm/ranges_copy_if.h @@ -36,8 +36,7 @@ namespace ranges { template using copy_if_result = in_out_result<_Ip, _Op>; -namespace __copy_if { -struct __fn { +struct __copy_if { template _LIBCPP_HIDE_FROM_ABI static constexpr copy_if_result<_InIter, _OutIter> __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { @@ -71,10 +70,9 @@ struct __fn { return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); } }; -} // namespace __copy_if inline namespace __cpo { -inline constexpr auto copy_if = __copy_if::__fn{}; +inline constexpr auto copy_if = __copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_copy_n.h b/libcxx/include/__algorithm/ranges_copy_n.h index 4353fa99278c..4407e07f5ca6 100644 --- a/libcxx/include/__algorithm/ranges_copy_n.h +++ b/libcxx/include/__algorithm/ranges_copy_n.h @@ -37,8 +37,7 @@ namespace ranges { template using copy_n_result = in_out_result<_Ip, _Op>; -namespace __copy_n { -struct __fn { +struct __copy_n { template _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) { @@ -65,10 +64,9 @@ struct __fn { return __go(std::move(__first), __n, std::move(__result)); } }; -} // namespace __copy_n inline namespace __cpo { -inline constexpr auto copy_n = __copy_n::__fn{}; +inline constexpr auto copy_n = __copy_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_count.h b/libcxx/include/__algorithm/ranges_count.h index 4f3511743870..2b3969e76307 100644 --- a/libcxx/include/__algorithm/ranges_count.h +++ b/libcxx/include/__algorithm/ranges_count.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __count { -struct __fn { +struct __count { template _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> @@ -50,10 +49,9 @@ struct __fn { return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); } }; -} // namespace __count inline namespace __cpo { -inline constexpr auto count = __count::__fn{}; +inline constexpr auto count = __count{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_count_if.h b/libcxx/include/__algorithm/ranges_count_if.h index 5f2396ff7d53..2663180242c1 100644 --- a/libcxx/include/__algorithm/ranges_count_if.h +++ b/libcxx/include/__algorithm/ranges_count_if.h @@ -44,8 +44,7 @@ __count_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { return __counter; } -namespace __count_if { -struct __fn { +struct __count_if { template _Sent, class _Proj = identity, @@ -63,10 +62,9 @@ struct __fn { return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } }; -} // namespace __count_if inline namespace __cpo { -inline constexpr auto count_if = __count_if::__fn{}; +inline constexpr auto count_if = __count_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_ends_with.h b/libcxx/include/__algorithm/ranges_ends_with.h index 06efdef36b7c..df7fad0bfc70 100644 --- a/libcxx/include/__algorithm/ranges_ends_with.h +++ b/libcxx/include/__algorithm/ranges_ends_with.h @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __ends_with { -struct __fn { +struct __ends_with { template _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional( _Iter1 __first1, @@ -185,10 +184,9 @@ struct __fn { } } }; -} // namespace __ends_with inline namespace __cpo { -inline constexpr auto ends_with = __ends_with::__fn{}; +inline constexpr auto ends_with = __ends_with{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_equal.h b/libcxx/include/__algorithm/ranges_equal.h index edbd0e3641c1..c26d13f00220 100644 --- a/libcxx/include/__algorithm/ranges_equal.h +++ b/libcxx/include/__algorithm/ranges_equal.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __equal { -struct __fn { +struct __equal { template _Sent1, input_iterator _Iter2, @@ -93,10 +92,9 @@ struct __fn { return false; } }; -} // namespace __equal inline namespace __cpo { -inline constexpr auto equal = __equal::__fn{}; +inline constexpr auto equal = __equal{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_equal_range.h b/libcxx/include/__algorithm/ranges_equal_range.h index 4a308e016b54..cc765f196648 100644 --- a/libcxx/include/__algorithm/ranges_equal_range.h +++ b/libcxx/include/__algorithm/ranges_equal_range.h @@ -38,9 +38,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __equal_range { - -struct __fn { +struct __equal_range { template _Sent, class _Tp, @@ -64,10 +62,8 @@ struct __fn { } }; -} // namespace __equal_range - inline namespace __cpo { -inline constexpr auto equal_range = __equal_range::__fn{}; +inline constexpr auto equal_range = __equal_range{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_fill.h b/libcxx/include/__algorithm/ranges_fill.h index 7a177d85e9f0..c248009f98fe 100644 --- a/libcxx/include/__algorithm/ranges_fill.h +++ b/libcxx/include/__algorithm/ranges_fill.h @@ -28,8 +28,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __fill { -struct __fn { +struct __fill { template _Iter, sentinel_for<_Iter> _Sent> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { @@ -46,10 +45,9 @@ struct __fn { return (*this)(ranges::begin(__range), ranges::end(__range), __value); } }; -} // namespace __fill inline namespace __cpo { -inline constexpr auto fill = __fill::__fn{}; +inline constexpr auto fill = __fill{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_fill_n.h b/libcxx/include/__algorithm/ranges_fill_n.h index a6e988c0089c..7a33268e1dd3 100644 --- a/libcxx/include/__algorithm/ranges_fill_n.h +++ b/libcxx/include/__algorithm/ranges_fill_n.h @@ -25,8 +25,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __fill_n { -struct __fn { +struct __fill_n { template _Iter> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const { @@ -37,10 +36,9 @@ struct __fn { return __first; } }; -} // namespace __fill_n inline namespace __cpo { -inline constexpr auto fill_n = __fill_n::__fn{}; +inline constexpr auto fill_n = __fill_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find.h b/libcxx/include/__algorithm/ranges_find.h index 6b0d5efe37ab..1eac4cfa02a4 100644 --- a/libcxx/include/__algorithm/ranges_find.h +++ b/libcxx/include/__algorithm/ranges_find.h @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find { -struct __fn { +struct __find { template _LIBCPP_HIDE_FROM_ABI static constexpr _Iter __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { @@ -64,10 +63,9 @@ struct __fn { return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj); } }; -} // namespace __find inline namespace __cpo { -inline constexpr auto find = __find::__fn{}; +inline constexpr auto find = __find{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find_end.h b/libcxx/include/__algorithm/ranges_find_end.h index e49e66dd4ac0..682724a48cd5 100644 --- a/libcxx/include/__algorithm/ranges_find_end.h +++ b/libcxx/include/__algorithm/ranges_find_end.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_end { -struct __fn { +struct __find_end { template _Sent1, forward_iterator _Iter2, @@ -87,10 +86,9 @@ struct __fn { return {__ret.first, __ret.second}; } }; -} // namespace __find_end inline namespace __cpo { -inline constexpr auto find_end = __find_end::__fn{}; +inline constexpr auto find_end = __find_end{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find_first_of.h b/libcxx/include/__algorithm/ranges_find_first_of.h index d92d9686bc44..102e16dd7a55 100644 --- a/libcxx/include/__algorithm/ranges_find_first_of.h +++ b/libcxx/include/__algorithm/ranges_find_first_of.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_first_of { -struct __fn { +struct __find_first_of { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl( _Iter1 __first1, @@ -90,10 +89,9 @@ struct __fn { __proj2); } }; -} // namespace __find_first_of inline namespace __cpo { -inline constexpr auto find_first_of = __find_first_of::__fn{}; +inline constexpr auto find_first_of = __find_first_of{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find_if.h b/libcxx/include/__algorithm/ranges_find_if.h index 888f9ec3cb2d..ed6406e6186a 100644 --- a/libcxx/include/__algorithm/ranges_find_if.h +++ b/libcxx/include/__algorithm/ranges_find_if.h @@ -42,8 +42,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pre return __first; } -namespace __find_if { -struct __fn { +struct __find_if { template _Sp, class _Proj = identity, @@ -59,10 +58,9 @@ struct __fn { return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } }; -} // namespace __find_if inline namespace __cpo { -inline constexpr auto find_if = __find_if::__fn{}; +inline constexpr auto find_if = __find_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find_if_not.h b/libcxx/include/__algorithm/ranges_find_if_not.h index ec19545b5a1b..9a359b2afdab 100644 --- a/libcxx/include/__algorithm/ranges_find_if_not.h +++ b/libcxx/include/__algorithm/ranges_find_if_not.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_if_not { -struct __fn { +struct __find_if_not { template _Sp, class _Proj = identity, @@ -53,10 +52,9 @@ struct __fn { return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); } }; -} // namespace __find_if_not inline namespace __cpo { -inline constexpr auto find_if_not = __find_if_not::__fn{}; +inline constexpr auto find_if_not = __find_if_not{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_find_last.h b/libcxx/include/__algorithm/ranges_find_last.h index 95f7e77b8ccb..838dd44e5d10 100644 --- a/libcxx/include/__algorithm/ranges_find_last.h +++ b/libcxx/include/__algorithm/ranges_find_last.h @@ -72,8 +72,7 @@ __find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) { } } -namespace __find_last { -struct __fn { +struct __find_last { template struct __op { const _Type& __value; @@ -97,10 +96,8 @@ struct __fn { return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj); } }; -} // namespace __find_last -namespace __find_last_if { -struct __fn { +struct __find_last_if { template struct __op { _Pred& __pred; @@ -127,10 +124,8 @@ struct __fn { return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); } }; -} // namespace __find_last_if -namespace __find_last_if_not { -struct __fn { +struct __find_last_if_not { template struct __op { _Pred& __pred; @@ -157,12 +152,11 @@ struct __fn { return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); } }; -} // namespace __find_last_if_not inline namespace __cpo { -inline constexpr auto find_last = __find_last::__fn{}; -inline constexpr auto find_last_if = __find_last_if::__fn{}; -inline constexpr auto find_last_if_not = __find_last_if_not::__fn{}; +inline constexpr auto find_last = __find_last{}; +inline constexpr auto find_last_if = __find_last_if{}; +inline constexpr auto find_last_if_not = __find_last_if_not{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_for_each.h b/libcxx/include/__algorithm/ranges_for_each.h index 225dc774c876..de39bc552275 100644 --- a/libcxx/include/__algorithm/ranges_for_each.h +++ b/libcxx/include/__algorithm/ranges_for_each.h @@ -36,8 +36,7 @@ namespace ranges { template using for_each_result = in_fun_result<_Iter, _Func>; -namespace __for_each { -struct __fn { +struct __for_each { private: template _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func> @@ -65,10 +64,9 @@ public: return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); } }; -} // namespace __for_each inline namespace __cpo { -inline constexpr auto for_each = __for_each::__fn{}; +inline constexpr auto for_each = __for_each{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_for_each_n.h b/libcxx/include/__algorithm/ranges_for_each_n.h index d1fdca34cc5a..603cb723233c 100644 --- a/libcxx/include/__algorithm/ranges_for_each_n.h +++ b/libcxx/include/__algorithm/ranges_for_each_n.h @@ -36,8 +36,7 @@ namespace ranges { template using for_each_n_result = in_fun_result<_Iter, _Func>; -namespace __for_each_n { -struct __fn { +struct __for_each_n { template > _Func> _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func> operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const { @@ -48,10 +47,9 @@ struct __fn { return {std::move(__first), std::move(__func)}; } }; -} // namespace __for_each_n inline namespace __cpo { -inline constexpr auto for_each_n = __for_each_n::__fn{}; +inline constexpr auto for_each_n = __for_each_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_generate.h b/libcxx/include/__algorithm/ranges_generate.h index e6467198e6ba..b94611d18263 100644 --- a/libcxx/include/__algorithm/ranges_generate.h +++ b/libcxx/include/__algorithm/ranges_generate.h @@ -32,9 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __generate { - -struct __fn { +struct __generate { template _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) { for (; __first != __last; ++__first) { @@ -57,10 +55,8 @@ struct __fn { } }; -} // namespace __generate - inline namespace __cpo { -inline constexpr auto generate = __generate::__fn{}; +inline constexpr auto generate = __generate{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_generate_n.h b/libcxx/include/__algorithm/ranges_generate_n.h index cd5fd7483ab2..702e9a949cb4 100644 --- a/libcxx/include/__algorithm/ranges_generate_n.h +++ b/libcxx/include/__algorithm/ranges_generate_n.h @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __generate_n { - -struct __fn { +struct __generate_n { template requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr _OutIter @@ -49,10 +47,8 @@ struct __fn { } }; -} // namespace __generate_n - inline namespace __cpo { -inline constexpr auto generate_n = __generate_n::__fn{}; +inline constexpr auto generate_n = __generate_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_includes.h b/libcxx/include/__algorithm/ranges_includes.h index c4c3b8ed088d..9145f3b5564f 100644 --- a/libcxx/include/__algorithm/ranges_includes.h +++ b/libcxx/include/__algorithm/ranges_includes.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __includes { - -struct __fn { +struct __includes { template _Sent1, input_iterator _Iter2, @@ -82,10 +80,8 @@ struct __fn { } }; -} // namespace __includes - inline namespace __cpo { -inline constexpr auto includes = __includes::__fn{}; +inline constexpr auto includes = __includes{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_inplace_merge.h b/libcxx/include/__algorithm/ranges_inplace_merge.h index d94c0ad46567..5879d0e7ef0f 100644 --- a/libcxx/include/__algorithm/ranges_inplace_merge.h +++ b/libcxx/include/__algorithm/ranges_inplace_merge.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __inplace_merge { - -struct __fn { +struct __inplace_merge { template _LIBCPP_HIDE_FROM_ABI static constexpr auto __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __inplace_merge - inline namespace __cpo { -inline constexpr auto inplace_merge = __inplace_merge::__fn{}; +inline constexpr auto inplace_merge = __inplace_merge{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_heap.h b/libcxx/include/__algorithm/ranges_is_heap.h index 3d9e18ce1d90..b4724abfb62a 100644 --- a/libcxx/include/__algorithm/ranges_is_heap.h +++ b/libcxx/include/__algorithm/ranges_is_heap.h @@ -34,9 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_heap { - -struct __fn { +struct __is_heap { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __is_heap - inline namespace __cpo { -inline constexpr auto is_heap = __is_heap::__fn{}; +inline constexpr auto is_heap = __is_heap{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_heap_until.h b/libcxx/include/__algorithm/ranges_is_heap_until.h index 7a2e1fc7705b..25f3b484faa6 100644 --- a/libcxx/include/__algorithm/ranges_is_heap_until.h +++ b/libcxx/include/__algorithm/ranges_is_heap_until.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_heap_until { - -struct __fn { +struct __is_heap_until { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __is_heap_until - inline namespace __cpo { -inline constexpr auto is_heap_until = __is_heap_until::__fn{}; +inline constexpr auto is_heap_until = __is_heap_until{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_partitioned.h b/libcxx/include/__algorithm/ranges_is_partitioned.h index 5be6fba46fd9..8092abfcd1de 100644 --- a/libcxx/include/__algorithm/ranges_is_partitioned.h +++ b/libcxx/include/__algorithm/ranges_is_partitioned.h @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_partitioned { -struct __fn { +struct __is_partitioned { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_partitioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -70,10 +69,9 @@ struct __fn { return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __is_partitioned inline namespace __cpo { -inline constexpr auto is_partitioned = __is_partitioned::__fn{}; +inline constexpr auto is_partitioned = __is_partitioned{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_permutation.h b/libcxx/include/__algorithm/ranges_is_permutation.h index 1f8d67007a57..53a431d2ba42 100644 --- a/libcxx/include/__algorithm/ranges_is_permutation.h +++ b/libcxx/include/__algorithm/ranges_is_permutation.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_permutation { -struct __fn { +struct __is_permutation { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl( _Iter1 __first1, @@ -91,10 +90,9 @@ struct __fn { __proj2); } }; -} // namespace __is_permutation inline namespace __cpo { -inline constexpr auto is_permutation = __is_permutation::__fn{}; +inline constexpr auto is_permutation = __is_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_sorted.h b/libcxx/include/__algorithm/ranges_is_sorted.h index 5b88d422b4b0..ab0670688a0e 100644 --- a/libcxx/include/__algorithm/ranges_is_sorted.h +++ b/libcxx/include/__algorithm/ranges_is_sorted.h @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_sorted { -struct __fn { +struct __is_sorted { template _Sent, class _Proj = identity, @@ -51,10 +50,9 @@ struct __fn { return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; } }; -} // namespace __is_sorted inline namespace __cpo { -inline constexpr auto is_sorted = __is_sorted::__fn{}; +inline constexpr auto is_sorted = __is_sorted{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_is_sorted_until.h b/libcxx/include/__algorithm/ranges_is_sorted_until.h index 54de530c8b2f..f2e51c264e4a 100644 --- a/libcxx/include/__algorithm/ranges_is_sorted_until.h +++ b/libcxx/include/__algorithm/ranges_is_sorted_until.h @@ -47,8 +47,7 @@ __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj return __i; } -namespace __is_sorted_until { -struct __fn { +struct __is_sorted_until { template _Sent, class _Proj = identity, @@ -66,10 +65,9 @@ struct __fn { return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } }; -} // namespace __is_sorted_until inline namespace __cpo { -inline constexpr auto is_sorted_until = __is_sorted_until::__fn{}; +inline constexpr auto is_sorted_until = __is_sorted_until{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_lexicographical_compare.h b/libcxx/include/__algorithm/ranges_lexicographical_compare.h index 6d82017e302a..024cc6b707ca 100644 --- a/libcxx/include/__algorithm/ranges_lexicographical_compare.h +++ b/libcxx/include/__algorithm/ranges_lexicographical_compare.h @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __lexicographical_compare { -struct __fn { +struct __lexicographical_compare { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __lexicographical_compare_impl( _Iter1 __first1, @@ -90,10 +89,9 @@ struct __fn { __proj2); } }; -} // namespace __lexicographical_compare inline namespace __cpo { -inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{}; +inline constexpr auto lexicographical_compare = __lexicographical_compare{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_lower_bound.h b/libcxx/include/__algorithm/ranges_lower_bound.h index 0651147e0424..d1b332849b8b 100644 --- a/libcxx/include/__algorithm/ranges_lower_bound.h +++ b/libcxx/include/__algorithm/ranges_lower_bound.h @@ -36,8 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __lower_bound { -struct __fn { +struct __lower_bound { template _Sent, class _Type, @@ -57,10 +56,9 @@ struct __fn { return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); } }; -} // namespace __lower_bound inline namespace __cpo { -inline constexpr auto lower_bound = __lower_bound::__fn{}; +inline constexpr auto lower_bound = __lower_bound{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_make_heap.h b/libcxx/include/__algorithm/ranges_make_heap.h index fe9c024fbf8a..97148f77b418 100644 --- a/libcxx/include/__algorithm/ranges_make_heap.h +++ b/libcxx/include/__algorithm/ranges_make_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __make_heap { - -struct __fn { +struct __make_heap { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __make_heap - inline namespace __cpo { -inline constexpr auto make_heap = __make_heap::__fn{}; +inline constexpr auto make_heap = __make_heap{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_max.h b/libcxx/include/__algorithm/ranges_max.h index d0ee6f314b0c..f631344422ed 100644 --- a/libcxx/include/__algorithm/ranges_max.h +++ b/libcxx/include/__algorithm/ranges_max.h @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __max { -struct __fn { +struct __max { template > _Comp = ranges::less> @@ -87,10 +86,9 @@ struct __fn { } } }; -} // namespace __max inline namespace __cpo { -inline constexpr auto max = __max::__fn{}; +inline constexpr auto max = __max{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_max_element.h b/libcxx/include/__algorithm/ranges_max_element.h index c57730927116..869f71ecc8d2 100644 --- a/libcxx/include/__algorithm/ranges_max_element.h +++ b/libcxx/include/__algorithm/ranges_max_element.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __max_element { -struct __fn { +struct __max_element { template _Sp, class _Proj = identity, @@ -53,10 +52,9 @@ struct __fn { return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); } }; -} // namespace __max_element inline namespace __cpo { -inline constexpr auto max_element = __max_element::__fn{}; +inline constexpr auto max_element = __max_element{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_merge.h b/libcxx/include/__algorithm/ranges_merge.h index bdf9a62d90bd..f3e0486fe488 100644 --- a/libcxx/include/__algorithm/ranges_merge.h +++ b/libcxx/include/__algorithm/ranges_merge.h @@ -39,42 +39,7 @@ namespace ranges { template using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __merge { - -template < class _InIter1, - class _Sent1, - class _InIter2, - class _Sent2, - class _OutIter, - class _Comp, - class _Proj1, - class _Proj2> -_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, - _InIter2&& __first2, - _Sent2&& __last2, - _OutIter&& __result, - _Comp&& __comp, - _Proj1&& __proj1, - _Proj2&& __proj2) { - for (; __first1 != __last1 && __first2 != __last2; ++__result) { - if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { - *__result = *__first2; - ++__first2; - } else { - *__result = *__first1; - ++__first1; - } - } - auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); - auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); - return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; -} - -struct __fn { +struct __merge { template _Sent1, input_iterator _InIter2, @@ -120,12 +85,43 @@ struct __fn { __proj1, __proj2); } + + template < class _InIter1, + class _Sent1, + class _InIter2, + class _Sent2, + class _OutIter, + class _Comp, + class _Proj1, + class _Proj2> + _LIBCPP_HIDE_FROM_ABI static constexpr merge_result<__remove_cvref_t<_InIter1>, + __remove_cvref_t<_InIter2>, + __remove_cvref_t<_OutIter>> + __merge_impl(_InIter1&& __first1, + _Sent1&& __last1, + _InIter2&& __first2, + _Sent2&& __last2, + _OutIter&& __result, + _Comp&& __comp, + _Proj1&& __proj1, + _Proj2&& __proj2) { + for (; __first1 != __last1 && __first2 != __last2; ++__result) { + if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { + *__result = *__first2; + ++__first2; + } else { + *__result = *__first1; + ++__first1; + } + } + auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); + auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); + return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; + } }; -} // namespace __merge - inline namespace __cpo { -inline constexpr auto merge = __merge::__fn{}; +inline constexpr auto merge = __merge{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_min.h b/libcxx/include/__algorithm/ranges_min.h index cc569d2a060c..302b5d7975b0 100644 --- a/libcxx/include/__algorithm/ranges_min.h +++ b/libcxx/include/__algorithm/ranges_min.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __min { -struct __fn { +struct __min { template > _Comp = ranges::less> @@ -79,10 +78,9 @@ struct __fn { } } }; -} // namespace __min inline namespace __cpo { -inline constexpr auto min = __min::__fn{}; +inline constexpr auto min = __min{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_min_element.h b/libcxx/include/__algorithm/ranges_min_element.h index 588ef258e26f..fb92ae56bcd6 100644 --- a/libcxx/include/__algorithm/ranges_min_element.h +++ b/libcxx/include/__algorithm/ranges_min_element.h @@ -46,8 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last, return __first; } -namespace __min_element { -struct __fn { +struct __min_element { template _Sp, class _Proj = identity, @@ -65,10 +64,9 @@ struct __fn { return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); } }; -} // namespace __min_element inline namespace __cpo { -inline constexpr auto min_element = __min_element::__fn{}; +inline constexpr auto min_element = __min_element{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h index 09cbefd91a8c..1b43b1e19cde 100644 --- a/libcxx/include/__algorithm/ranges_minmax.h +++ b/libcxx/include/__algorithm/ranges_minmax.h @@ -47,8 +47,7 @@ namespace ranges { template using minmax_result = min_max_result<_T1>; -namespace __minmax { -struct __fn { +struct __minmax { template > _Comp = ranges::less> @@ -159,10 +158,9 @@ struct __fn { } } }; -} // namespace __minmax inline namespace __cpo { -inline constexpr auto minmax = __minmax::__fn{}; +inline constexpr auto minmax = __minmax{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_minmax_element.h b/libcxx/include/__algorithm/ranges_minmax_element.h index 4bf6d2404e46..e1a22dde0955 100644 --- a/libcxx/include/__algorithm/ranges_minmax_element.h +++ b/libcxx/include/__algorithm/ranges_minmax_element.h @@ -40,8 +40,7 @@ namespace ranges { template using minmax_element_result = min_max_result<_T1>; -namespace __minmax_element { -struct __fn { +struct __minmax_element { template _Sp, class _Proj = identity, @@ -61,10 +60,9 @@ struct __fn { return {__ret.first, __ret.second}; } }; -} // namespace __minmax_element inline namespace __cpo { -inline constexpr auto minmax_element = __minmax_element::__fn{}; +inline constexpr auto minmax_element = __minmax_element{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_mismatch.h b/libcxx/include/__algorithm/ranges_mismatch.h index c4bf0022a9bc..b35747dfa43a 100644 --- a/libcxx/include/__algorithm/ranges_mismatch.h +++ b/libcxx/include/__algorithm/ranges_mismatch.h @@ -39,8 +39,7 @@ namespace ranges { template using mismatch_result = in_in_result<_I1, _I2>; -namespace __mismatch { -struct __fn { +struct __mismatch { template static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { @@ -84,10 +83,9 @@ struct __fn { ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2); } }; -} // namespace __mismatch inline namespace __cpo { -constexpr inline auto mismatch = __mismatch::__fn{}; +constexpr inline auto mismatch = __mismatch{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_move.h b/libcxx/include/__algorithm/ranges_move.h index be869f36c973..02bf7fd00619 100644 --- a/libcxx/include/__algorithm/ranges_move.h +++ b/libcxx/include/__algorithm/ranges_move.h @@ -35,8 +35,7 @@ namespace ranges { template using move_result = in_out_result<_InIter, _OutIter>; -namespace __move { -struct __fn { +struct __move { template _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { @@ -58,10 +57,9 @@ struct __fn { return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); } }; -} // namespace __move inline namespace __cpo { -inline constexpr auto move = __move::__fn{}; +inline constexpr auto move = __move{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_move_backward.h b/libcxx/include/__algorithm/ranges_move_backward.h index 6d4071a33b81..4737e6c9756d 100644 --- a/libcxx/include/__algorithm/ranges_move_backward.h +++ b/libcxx/include/__algorithm/ranges_move_backward.h @@ -37,8 +37,7 @@ namespace ranges { template using move_backward_result = in_out_result<_InIter, _OutIter>; -namespace __move_backward { -struct __fn { +struct __move_backward { template _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { @@ -60,10 +59,9 @@ struct __fn { return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); } }; -} // namespace __move_backward inline namespace __cpo { -inline constexpr auto move_backward = __move_backward::__fn{}; +inline constexpr auto move_backward = __move_backward{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_next_permutation.h b/libcxx/include/__algorithm/ranges_next_permutation.h index 18535e0a6254..1b485423e892 100644 --- a/libcxx/include/__algorithm/ranges_next_permutation.h +++ b/libcxx/include/__algorithm/ranges_next_permutation.h @@ -40,9 +40,7 @@ namespace ranges { template using next_permutation_result = in_found_result<_InIter>; -namespace __next_permutation { - -struct __fn { +struct __next_permutation { template _Sent, class _Comp = ranges::less, class _Proj = identity> requires sortable<_Iter, _Comp, _Proj> _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter> @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __next_permutation - inline namespace __cpo { -constexpr inline auto next_permutation = __next_permutation::__fn{}; +constexpr inline auto next_permutation = __next_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_none_of.h b/libcxx/include/__algorithm/ranges_none_of.h index 7df3c1829fcf..a1612826220d 100644 --- a/libcxx/include/__algorithm/ranges_none_of.h +++ b/libcxx/include/__algorithm/ranges_none_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __none_of { -struct __fn { +struct __none_of { template _LIBCPP_HIDE_FROM_ABI constexpr static bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -59,10 +58,9 @@ struct __fn { return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __none_of inline namespace __cpo { -inline constexpr auto none_of = __none_of::__fn{}; +inline constexpr auto none_of = __none_of{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_nth_element.h b/libcxx/include/__algorithm/ranges_nth_element.h index 90ade9efe10d..e92c51e713cb 100644 --- a/libcxx/include/__algorithm/ranges_nth_element.h +++ b/libcxx/include/__algorithm/ranges_nth_element.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __nth_element { - -struct __fn { +struct __nth_element { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __nth_element - inline namespace __cpo { -inline constexpr auto nth_element = __nth_element::__fn{}; +inline constexpr auto nth_element = __nth_element{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_partial_sort.h b/libcxx/include/__algorithm/ranges_partial_sort.h index c67247d2e0a7..fc8a1f7d9306 100644 --- a/libcxx/include/__algorithm/ranges_partial_sort.h +++ b/libcxx/include/__algorithm/ranges_partial_sort.h @@ -41,9 +41,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partial_sort { - -struct __fn { +struct __partial_sort { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __partial_sort - inline namespace __cpo { -inline constexpr auto partial_sort = __partial_sort::__fn{}; +inline constexpr auto partial_sort = __partial_sort{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_partial_sort_copy.h b/libcxx/include/__algorithm/ranges_partial_sort_copy.h index b3bdeb78fb6f..f221504a8cae 100644 --- a/libcxx/include/__algorithm/ranges_partial_sort_copy.h +++ b/libcxx/include/__algorithm/ranges_partial_sort_copy.h @@ -42,9 +42,7 @@ namespace ranges { template using partial_sort_copy_result = in_out_result<_InIter, _OutIter>; -namespace __partial_sort_copy { - -struct __fn { +struct __partial_sort_copy { template _Sent1, random_access_iterator _Iter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __partial_sort_copy - inline namespace __cpo { -inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{}; +inline constexpr auto partial_sort_copy = __partial_sort_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_partition.h b/libcxx/include/__algorithm/ranges_partition.h index a67ac4c96757..7058cb0c3969 100644 --- a/libcxx/include/__algorithm/ranges_partition.h +++ b/libcxx/include/__algorithm/ranges_partition.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partition { - -struct __fn { +struct __partition { template _LIBCPP_HIDE_FROM_ABI static constexpr subrange<__remove_cvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { @@ -72,10 +70,8 @@ struct __fn { } }; -} // namespace __partition - inline namespace __cpo { -inline constexpr auto partition = __partition::__fn{}; +inline constexpr auto partition = __partition{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_partition_copy.h b/libcxx/include/__algorithm/ranges_partition_copy.h index d60c865dd2a8..47878a401723 100644 --- a/libcxx/include/__algorithm/ranges_partition_copy.h +++ b/libcxx/include/__algorithm/ranges_partition_copy.h @@ -38,9 +38,7 @@ namespace ranges { template using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>; -namespace __partition_copy { - -struct __fn { +struct __partition_copy { // TODO(ranges): delegate to the classic algorithm. template _LIBCPP_HIDE_FROM_ABI constexpr static partition_copy_result<__remove_cvref_t<_InIter>, @@ -94,10 +92,8 @@ struct __fn { } }; -} // namespace __partition_copy - inline namespace __cpo { -inline constexpr auto partition_copy = __partition_copy::__fn{}; +inline constexpr auto partition_copy = __partition_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_partition_point.h b/libcxx/include/__algorithm/ranges_partition_point.h index c5b11b5fed19..324efbb86d64 100644 --- a/libcxx/include/__algorithm/ranges_partition_point.h +++ b/libcxx/include/__algorithm/ranges_partition_point.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partition_point { - -struct __fn { +struct __partition_point { // TODO(ranges): delegate to the classic algorithm. template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter @@ -77,10 +75,8 @@ struct __fn { } }; -} // namespace __partition_point - inline namespace __cpo { -inline constexpr auto partition_point = __partition_point::__fn{}; +inline constexpr auto partition_point = __partition_point{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_pop_heap.h b/libcxx/include/__algorithm/ranges_pop_heap.h index 01f92c0f2288..eccf54c094e3 100644 --- a/libcxx/include/__algorithm/ranges_pop_heap.h +++ b/libcxx/include/__algorithm/ranges_pop_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __pop_heap { - -struct __fn { +struct __pop_heap { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -70,10 +68,8 @@ struct __fn { } }; -} // namespace __pop_heap - inline namespace __cpo { -inline constexpr auto pop_heap = __pop_heap::__fn{}; +inline constexpr auto pop_heap = __pop_heap{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_prev_permutation.h b/libcxx/include/__algorithm/ranges_prev_permutation.h index 225cee9b75ec..f2294b1cb00b 100644 --- a/libcxx/include/__algorithm/ranges_prev_permutation.h +++ b/libcxx/include/__algorithm/ranges_prev_permutation.h @@ -40,9 +40,7 @@ namespace ranges { template using prev_permutation_result = in_found_result<_InIter>; -namespace __prev_permutation { - -struct __fn { +struct __prev_permutation { template _Sent, class _Comp = ranges::less, class _Proj = identity> requires sortable<_Iter, _Comp, _Proj> _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter> @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __prev_permutation - inline namespace __cpo { -constexpr inline auto prev_permutation = __prev_permutation::__fn{}; +constexpr inline auto prev_permutation = __prev_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_push_heap.h b/libcxx/include/__algorithm/ranges_push_heap.h index 9d187af38c53..c5e0465bdcfe 100644 --- a/libcxx/include/__algorithm/ranges_push_heap.h +++ b/libcxx/include/__algorithm/ranges_push_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __push_heap { - -struct __fn { +struct __push_heap { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __push_heap - inline namespace __cpo { -inline constexpr auto push_heap = __push_heap::__fn{}; +inline constexpr auto push_heap = __push_heap{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_remove.h b/libcxx/include/__algorithm/ranges_remove.h index 17c3a2c5cd06..6fbc49eba8a7 100644 --- a/libcxx/include/__algorithm/ranges_remove.h +++ b/libcxx/include/__algorithm/ranges_remove.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __remove { -struct __fn { +struct __remove { template _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> @@ -52,10 +51,9 @@ struct __fn { return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __remove inline namespace __cpo { -inline constexpr auto remove = __remove::__fn{}; +inline constexpr auto remove = __remove{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_remove_copy.h b/libcxx/include/__algorithm/ranges_remove_copy.h index 84529eceac68..764c52ee16b2 100644 --- a/libcxx/include/__algorithm/ranges_remove_copy.h +++ b/libcxx/include/__algorithm/ranges_remove_copy.h @@ -38,9 +38,7 @@ namespace ranges { template using remove_copy_result = in_out_result<_InIter, _OutIter>; -namespace __remove_copy { - -struct __fn { +struct __remove_copy { template _Sent, weakly_incrementable _OutIter, @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __remove_copy - inline namespace __cpo { -inline constexpr auto remove_copy = __remove_copy::__fn{}; +inline constexpr auto remove_copy = __remove_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_remove_copy_if.h b/libcxx/include/__algorithm/ranges_remove_copy_if.h index 56fe01753312..87136ae8258d 100644 --- a/libcxx/include/__algorithm/ranges_remove_copy_if.h +++ b/libcxx/include/__algorithm/ranges_remove_copy_if.h @@ -53,9 +53,7 @@ __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& _ return {std::move(__first), std::move(__result)}; } -namespace __remove_copy_if { - -struct __fn { +struct __remove_copy_if { template _Sent, weakly_incrementable _OutIter, @@ -79,10 +77,8 @@ struct __fn { } }; -} // namespace __remove_copy_if - inline namespace __cpo { -inline constexpr auto remove_copy_if = __remove_copy_if::__fn{}; +inline constexpr auto remove_copy_if = __remove_copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_remove_if.h b/libcxx/include/__algorithm/ranges_remove_if.h index 0ea5d9a01b88..384b3d41d080 100644 --- a/libcxx/include/__algorithm/ranges_remove_if.h +++ b/libcxx/include/__algorithm/ranges_remove_if.h @@ -53,8 +53,7 @@ __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { return {__new_end, __i}; } -namespace __remove_if { -struct __fn { +struct __remove_if { template _Sent, class _Proj = identity, @@ -73,10 +72,9 @@ struct __fn { return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __remove_if inline namespace __cpo { -inline constexpr auto remove_if = __remove_if::__fn{}; +inline constexpr auto remove_if = __remove_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_replace.h b/libcxx/include/__algorithm/ranges_replace.h index 2b88dc032972..15b1f38554a8 100644 --- a/libcxx/include/__algorithm/ranges_replace.h +++ b/libcxx/include/__algorithm/ranges_replace.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __replace { -struct __fn { +struct __replace { template _Sent, class _Type1, class _Type2, class _Proj = identity> requires indirectly_writable<_Iter, const _Type2&> && indirect_binary_predicate, const _Type1*> @@ -52,10 +51,9 @@ struct __fn { return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); } }; -} // namespace __replace inline namespace __cpo { -inline constexpr auto replace = __replace::__fn{}; +inline constexpr auto replace = __replace{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_replace_copy.h b/libcxx/include/__algorithm/ranges_replace_copy.h index 633f993e5c94..7ab1c71543e2 100644 --- a/libcxx/include/__algorithm/ranges_replace_copy.h +++ b/libcxx/include/__algorithm/ranges_replace_copy.h @@ -38,9 +38,7 @@ namespace ranges { template using replace_copy_result = in_out_result<_InIter, _OutIter>; -namespace __replace_copy { - -struct __fn { +struct __replace_copy { template _Sent, class _OldType, @@ -77,10 +75,8 @@ struct __fn { } }; -} // namespace __replace_copy - inline namespace __cpo { -inline constexpr auto replace_copy = __replace_copy::__fn{}; +inline constexpr auto replace_copy = __replace_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_replace_copy_if.h b/libcxx/include/__algorithm/ranges_replace_copy_if.h index e065c3ac0acc..852ec45edaef 100644 --- a/libcxx/include/__algorithm/ranges_replace_copy_if.h +++ b/libcxx/include/__algorithm/ranges_replace_copy_if.h @@ -52,9 +52,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __repl return {std::move(__first), std::move(__result)}; } -namespace __replace_copy_if { - -struct __fn { +struct __replace_copy_if { template _Sent, class _Type, @@ -82,10 +80,8 @@ struct __fn { } }; -} // namespace __replace_copy_if - inline namespace __cpo { -inline constexpr auto replace_copy_if = __replace_copy_if::__fn{}; +inline constexpr auto replace_copy_if = __replace_copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_replace_if.h b/libcxx/include/__algorithm/ranges_replace_if.h index 6445f42aea19..baa566810b5d 100644 --- a/libcxx/include/__algorithm/ranges_replace_if.h +++ b/libcxx/include/__algorithm/ranges_replace_if.h @@ -42,8 +42,7 @@ __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new return __first; } -namespace __replace_if { -struct __fn { +struct __replace_if { template _Sent, class _Type, @@ -65,10 +64,9 @@ struct __fn { return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); } }; -} // namespace __replace_if inline namespace __cpo { -inline constexpr auto replace_if = __replace_if::__fn{}; +inline constexpr auto replace_if = __replace_if{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_reverse.h b/libcxx/include/__algorithm/ranges_reverse.h index 9ec865995b4a..4e8211871977 100644 --- a/libcxx/include/__algorithm/ranges_reverse.h +++ b/libcxx/include/__algorithm/ranges_reverse.h @@ -27,8 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __reverse { -struct __fn { +struct __reverse { template _Sent> requires permutable<_Iter> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last) const { @@ -65,10 +64,9 @@ struct __fn { return (*this)(ranges::begin(__range), ranges::end(__range)); } }; -} // namespace __reverse inline namespace __cpo { -inline constexpr auto reverse = __reverse::__fn{}; +inline constexpr auto reverse = __reverse{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_reverse_copy.h b/libcxx/include/__algorithm/ranges_reverse_copy.h index 60043787a717..e5ca5cf652dc 100644 --- a/libcxx/include/__algorithm/ranges_reverse_copy.h +++ b/libcxx/include/__algorithm/ranges_reverse_copy.h @@ -37,8 +37,7 @@ namespace ranges { template using reverse_copy_result = in_out_result<_InIter, _OutIter>; -namespace __reverse_copy { -struct __fn { +struct __reverse_copy { template _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<_InIter, _OutIter> @@ -54,10 +53,9 @@ struct __fn { return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)}; } }; -} // namespace __reverse_copy inline namespace __cpo { -inline constexpr auto reverse_copy = __reverse_copy::__fn{}; +inline constexpr auto reverse_copy = __reverse_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_rotate.h b/libcxx/include/__algorithm/ranges_rotate.h index 8d33a6f0799b..c1affc684ae4 100644 --- a/libcxx/include/__algorithm/ranges_rotate.h +++ b/libcxx/include/__algorithm/ranges_rotate.h @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __rotate { - -struct __fn { +struct __rotate { template _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)); @@ -55,10 +53,8 @@ struct __fn { } }; -} // namespace __rotate - inline namespace __cpo { -inline constexpr auto rotate = __rotate::__fn{}; +inline constexpr auto rotate = __rotate{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_rotate_copy.h b/libcxx/include/__algorithm/ranges_rotate_copy.h index 26fe110b5389..c0b4264a1b25 100644 --- a/libcxx/include/__algorithm/ranges_rotate_copy.h +++ b/libcxx/include/__algorithm/ranges_rotate_copy.h @@ -34,8 +34,7 @@ namespace ranges { template using rotate_copy_result = in_out_result<_InIter, _OutIter>; -namespace __rotate_copy { -struct __fn { +struct __rotate_copy { template _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter> @@ -52,10 +51,9 @@ struct __fn { return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result)); } }; -} // namespace __rotate_copy inline namespace __cpo { -inline constexpr auto rotate_copy = __rotate_copy::__fn{}; +inline constexpr auto rotate_copy = __rotate_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_sample.h b/libcxx/include/__algorithm/ranges_sample.h index e4f60a7b66be..a3b29608150d 100644 --- a/libcxx/include/__algorithm/ranges_sample.h +++ b/libcxx/include/__algorithm/ranges_sample.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sample { - -struct __fn { +struct __sample { template _Sent, weakly_incrementable _OutIter, class _Gen> requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> && uniform_random_bit_generator> @@ -58,10 +56,8 @@ struct __fn { } }; -} // namespace __sample - inline namespace __cpo { -inline constexpr auto sample = __sample::__fn{}; +inline constexpr auto sample = __sample{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_search.h b/libcxx/include/__algorithm/ranges_search.h index 55294c60631b..b71151203963 100644 --- a/libcxx/include/__algorithm/ranges_search.h +++ b/libcxx/include/__algorithm/ranges_search.h @@ -33,8 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __search { -struct __fn { +struct __search { template _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl( _Iter1 __first1, @@ -120,10 +119,9 @@ struct __fn { __proj2); } }; -} // namespace __search inline namespace __cpo { -inline constexpr auto search = __search::__fn{}; +inline constexpr auto search = __search{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_search_n.h b/libcxx/include/__algorithm/ranges_search_n.h index 56e12755b9bf..81b568c0965f 100644 --- a/libcxx/include/__algorithm/ranges_search_n.h +++ b/libcxx/include/__algorithm/ranges_search_n.h @@ -39,8 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __search_n { -struct __fn { +struct __search_n { template _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl( _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { @@ -100,10 +99,9 @@ struct __fn { return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj); } }; -} // namespace __search_n inline namespace __cpo { -inline constexpr auto search_n = __search_n::__fn{}; +inline constexpr auto search_n = __search_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_set_difference.h b/libcxx/include/__algorithm/ranges_set_difference.h index 0841fb4ffd0c..aa36e358ef6f 100644 --- a/libcxx/include/__algorithm/ranges_set_difference.h +++ b/libcxx/include/__algorithm/ranges_set_difference.h @@ -42,9 +42,7 @@ namespace ranges { template using set_difference_result = in_out_result<_InIter, _OutIter>; -namespace __set_difference { - -struct __fn { +struct __set_difference { template _Sent1, input_iterator _InIter2, @@ -93,10 +91,8 @@ struct __fn { } }; -} // namespace __set_difference - inline namespace __cpo { -inline constexpr auto set_difference = __set_difference::__fn{}; +inline constexpr auto set_difference = __set_difference{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_set_intersection.h b/libcxx/include/__algorithm/ranges_set_intersection.h index 9427379745b6..068794cf1b14 100644 --- a/libcxx/include/__algorithm/ranges_set_intersection.h +++ b/libcxx/include/__algorithm/ranges_set_intersection.h @@ -40,9 +40,7 @@ namespace ranges { template using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_intersection { - -struct __fn { +struct __set_intersection { template _Sent1, input_iterator _InIter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __set_intersection - inline namespace __cpo { -inline constexpr auto set_intersection = __set_intersection::__fn{}; +inline constexpr auto set_intersection = __set_intersection{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h index 995eb0999d94..e3b73c3eb1cf 100644 --- a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h +++ b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h @@ -40,9 +40,7 @@ namespace ranges { template using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_symmetric_difference { - -struct __fn { +struct __set_symmetric_difference { template _Sent1, input_iterator _InIter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __set_symmetric_difference - inline namespace __cpo { -inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{}; +inline constexpr auto set_symmetric_difference = __set_symmetric_difference{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_set_union.h b/libcxx/include/__algorithm/ranges_set_union.h index e870e390cc66..f2e3ddb89d7b 100644 --- a/libcxx/include/__algorithm/ranges_set_union.h +++ b/libcxx/include/__algorithm/ranges_set_union.h @@ -43,9 +43,7 @@ namespace ranges { template using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_union { - -struct __fn { +struct __set_union { template _Sent1, input_iterator _InIter2, @@ -99,10 +97,8 @@ struct __fn { } }; -} // namespace __set_union - inline namespace __cpo { -inline constexpr auto set_union = __set_union::__fn{}; +inline constexpr auto set_union = __set_union{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_shuffle.h b/libcxx/include/__algorithm/ranges_shuffle.h index ab98ea22caab..87cb3685bb95 100644 --- a/libcxx/include/__algorithm/ranges_shuffle.h +++ b/libcxx/include/__algorithm/ranges_shuffle.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __shuffle { - -struct __fn { +struct __shuffle { template _Sent, class _Gen> requires permutable<_Iter> && uniform_random_bit_generator> _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const { @@ -56,10 +54,8 @@ struct __fn { } }; -} // namespace __shuffle - inline namespace __cpo { -inline constexpr auto shuffle = __shuffle::__fn{}; +inline constexpr auto shuffle = __shuffle{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_sort.h b/libcxx/include/__algorithm/ranges_sort.h index 0296c146b3ed..2afad4c41301 100644 --- a/libcxx/include/__algorithm/ranges_sort.h +++ b/libcxx/include/__algorithm/ranges_sort.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sort { - -struct __fn { +struct __sort { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __sort - inline namespace __cpo { -inline constexpr auto sort = __sort::__fn{}; +inline constexpr auto sort = __sort{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_sort_heap.h b/libcxx/include/__algorithm/ranges_sort_heap.h index bab30df1708c..d3e20874fac5 100644 --- a/libcxx/include/__algorithm/ranges_sort_heap.h +++ b/libcxx/include/__algorithm/ranges_sort_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sort_heap { - -struct __fn { +struct __sort_heap { template _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __sort_heap - inline namespace __cpo { -inline constexpr auto sort_heap = __sort_heap::__fn{}; +inline constexpr auto sort_heap = __sort_heap{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_stable_partition.h b/libcxx/include/__algorithm/ranges_stable_partition.h index f34027ff772c..cfc02e1e97b3 100644 --- a/libcxx/include/__algorithm/ranges_stable_partition.h +++ b/libcxx/include/__algorithm/ranges_stable_partition.h @@ -42,9 +42,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __stable_partition { - -struct __fn { +struct __stable_partition { template _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>> __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { @@ -76,10 +74,8 @@ struct __fn { } }; -} // namespace __stable_partition - inline namespace __cpo { -inline constexpr auto stable_partition = __stable_partition::__fn{}; +inline constexpr auto stable_partition = __stable_partition{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_stable_sort.h b/libcxx/include/__algorithm/ranges_stable_sort.h index 93909e253cc0..9c7df80ae987 100644 --- a/libcxx/include/__algorithm/ranges_stable_sort.h +++ b/libcxx/include/__algorithm/ranges_stable_sort.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __stable_sort { - -struct __fn { +struct __stable_sort { template _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { auto __last_iter = ranges::next(__first, __last); @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __stable_sort - inline namespace __cpo { -inline constexpr auto stable_sort = __stable_sort::__fn{}; +inline constexpr auto stable_sort = __stable_sort{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_starts_with.h b/libcxx/include/__algorithm/ranges_starts_with.h index 17084e4f2433..ae145d59010a 100644 --- a/libcxx/include/__algorithm/ranges_starts_with.h +++ b/libcxx/include/__algorithm/ranges_starts_with.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __starts_with { -struct __fn { +struct __starts_with { template _Sent1, input_iterator _Iter2, @@ -50,7 +49,7 @@ struct __fn { _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { - return __mismatch::__fn::__go( + return __mismatch::__go( std::move(__first1), std::move(__last1), std::move(__first2), @@ -69,7 +68,7 @@ struct __fn { requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { - return __mismatch::__fn::__go( + return __mismatch::__go( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), @@ -80,9 +79,8 @@ struct __fn { .in2 == ranges::end(__range2); } }; -} // namespace __starts_with inline namespace __cpo { -inline constexpr auto starts_with = __starts_with::__fn{}; +inline constexpr auto starts_with = __starts_with{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_swap_ranges.h b/libcxx/include/__algorithm/ranges_swap_ranges.h index b6d9f618395a..ab6db50d8a13 100644 --- a/libcxx/include/__algorithm/ranges_swap_ranges.h +++ b/libcxx/include/__algorithm/ranges_swap_ranges.h @@ -36,8 +36,7 @@ namespace ranges { template using swap_ranges_result = in_in_result<_I1, _I2>; -namespace __swap_ranges { -struct __fn { +struct __swap_ranges { template _S1, input_iterator _I2, sentinel_for<_I2> _S2> requires indirectly_swappable<_I1, _I2> _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> @@ -54,10 +53,9 @@ struct __fn { return operator()(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2)); } }; -} // namespace __swap_ranges inline namespace __cpo { -inline constexpr auto swap_ranges = __swap_ranges::__fn{}; +inline constexpr auto swap_ranges = __swap_ranges{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_transform.h b/libcxx/include/__algorithm/ranges_transform.h index 7850ec4f8465..091311821968 100644 --- a/libcxx/include/__algorithm/ranges_transform.h +++ b/libcxx/include/__algorithm/ranges_transform.h @@ -41,8 +41,7 @@ using unary_transform_result = in_out_result<_Ip, _Op>; template using binary_transform_result = in_in_out_result<_I1, _I2, _O1>; -namespace __transform { -struct __fn { +struct __transform { private: template _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter> @@ -161,10 +160,9 @@ public: __projection2); } }; -} // namespace __transform inline namespace __cpo { -inline constexpr auto transform = __transform::__fn{}; +inline constexpr auto transform = __transform{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_unique.h b/libcxx/include/__algorithm/ranges_unique.h index 7a9b78432187..a817359abd88 100644 --- a/libcxx/include/__algorithm/ranges_unique.h +++ b/libcxx/include/__algorithm/ranges_unique.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __unique { - -struct __fn { +struct __unique { template _Sent, class _Proj = identity, @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __unique - inline namespace __cpo { -inline constexpr auto unique = __unique::__fn{}; +inline constexpr auto unique = __unique{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_unique_copy.h b/libcxx/include/__algorithm/ranges_unique_copy.h index 61133885ae80..3b4a64e94ca1 100644 --- a/libcxx/include/__algorithm/ranges_unique_copy.h +++ b/libcxx/include/__algorithm/ranges_unique_copy.h @@ -44,12 +44,10 @@ namespace ranges { template using unique_copy_result = in_out_result<_InIter, _OutIter>; -namespace __unique_copy { - template concept __can_reread_from_output = (input_iterator<_OutIter> && same_as, iter_value_t<_OutIter>>); -struct __fn { +struct __unique_copy { template static consteval auto __get_algo_tag() { if constexpr (forward_iterator<_InIter>) { @@ -104,10 +102,8 @@ struct __fn { } }; -} // namespace __unique_copy - inline namespace __cpo { -inline constexpr auto unique_copy = __unique_copy::__fn{}; +inline constexpr auto unique_copy = __unique_copy{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__algorithm/ranges_upper_bound.h b/libcxx/include/__algorithm/ranges_upper_bound.h index fa6fa7f70ed5..4b2835d4d58d 100644 --- a/libcxx/include/__algorithm/ranges_upper_bound.h +++ b/libcxx/include/__algorithm/ranges_upper_bound.h @@ -30,8 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __upper_bound { -struct __fn { +struct __upper_bound { template _Sent, class _Type, @@ -60,10 +59,9 @@ struct __fn { ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj); } }; -} // namespace __upper_bound inline namespace __cpo { -inline constexpr auto upper_bound = __upper_bound::__fn{}; +inline constexpr auto upper_bound = __upper_bound{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h index 296db1aaab65..57b1b845f1af 100644 --- a/libcxx/include/__iterator/advance.h +++ b/libcxx/include/__iterator/advance.h @@ -76,9 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i // [range.iter.op.advance] namespace ranges { -namespace __advance { - -struct __fn { +struct __advance { private: template _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { @@ -189,10 +187,8 @@ public: } }; -} // namespace __advance - inline namespace __cpo { -inline constexpr auto advance = __advance::__fn{}; +inline constexpr auto advance = __advance{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__iterator/distance.h b/libcxx/include/__iterator/distance.h index 75bd49c9ae73..1732aa527f64 100644 --- a/libcxx/include/__iterator/distance.h +++ b/libcxx/include/__iterator/distance.h @@ -52,9 +52,7 @@ distance(_InputIter __first, _InputIter __last) { // [range.iter.op.distance] namespace ranges { -namespace __distance { - -struct __fn { +struct __distance { template _Sp> requires(!sized_sentinel_for<_Sp, _Ip>) _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { @@ -85,10 +83,8 @@ struct __fn { } }; -} // namespace __distance - inline namespace __cpo { -inline constexpr auto distance = __distance::__fn{}; +inline constexpr auto distance = __distance{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__iterator/next.h b/libcxx/include/__iterator/next.h index 21d3688ad9eb..fb6c8ea6d755 100644 --- a/libcxx/include/__iterator/next.h +++ b/libcxx/include/__iterator/next.h @@ -41,9 +41,7 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = // [range.iter.op.next] namespace ranges { -namespace __next { - -struct __fn { +struct __next { template _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { ++__x; @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __next - inline namespace __cpo { -inline constexpr auto next = __next::__fn{}; +inline constexpr auto next = __next{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__iterator/prev.h b/libcxx/include/__iterator/prev.h index 2f0e6a088edb..e950d8dc4147 100644 --- a/libcxx/include/__iterator/prev.h +++ b/libcxx/include/__iterator/prev.h @@ -40,9 +40,7 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = // [range.iter.op.prev] namespace ranges { -namespace __prev { - -struct __fn { +struct __prev { template _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { --__x; @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __prev - inline namespace __cpo { -inline constexpr auto prev = __prev::__fn{}; +inline constexpr auto prev = __prev{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__memory/ranges_construct_at.h b/libcxx/include/__memory/ranges_construct_at.h index f731e75e7bdc..b7523d4ba4b8 100644 --- a/libcxx/include/__memory/ranges_construct_at.h +++ b/libcxx/include/__memory/ranges_construct_at.h @@ -38,43 +38,33 @@ namespace ranges { // construct_at -namespace __construct_at { - -struct __fn { +struct __construct_at { template ()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const { return std::construct_at(__location, std::forward<_Args>(__args)...); } }; -} // namespace __construct_at - inline namespace __cpo { -inline constexpr auto construct_at = __construct_at::__fn{}; +inline constexpr auto construct_at = __construct_at{}; } // namespace __cpo // destroy_at -namespace __destroy_at { - -struct __fn { +struct __destroy_at { template _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept { std::destroy_at(__location); } }; -} // namespace __destroy_at - inline namespace __cpo { -inline constexpr auto destroy_at = __destroy_at::__fn{}; +inline constexpr auto destroy_at = __destroy_at{}; } // namespace __cpo // destroy -namespace __destroy { - -struct __fn { +struct __destroy { template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> requires destructible> _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { @@ -88,17 +78,13 @@ struct __fn { } }; -} // namespace __destroy - inline namespace __cpo { -inline constexpr auto destroy = __destroy::__fn{}; +inline constexpr auto destroy = __destroy{}; } // namespace __cpo // destroy_n -namespace __destroy_n { - -struct __fn { +struct __destroy_n { template <__nothrow_input_iterator _InputIterator> requires destructible> _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator @@ -107,10 +93,8 @@ struct __fn { } }; -} // namespace __destroy_n - inline namespace __cpo { -inline constexpr auto destroy_n = __destroy_n::__fn{}; +inline constexpr auto destroy_n = __destroy_n{}; } // namespace __cpo } // namespace ranges diff --git a/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/libcxx/include/__memory/ranges_uninitialized_algorithms.h index 90090055bbbb..4815ac6e5de9 100644 --- a/libcxx/include/__memory/ranges_uninitialized_algorithms.h +++ b/libcxx/include/__memory/ranges_uninitialized_algorithms.h @@ -42,9 +42,7 @@ namespace ranges { // uninitialized_default_construct -namespace __uninitialized_default_construct { - -struct __fn { +struct __uninitialized_default_construct { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { @@ -59,17 +57,13 @@ struct __fn { } }; -} // namespace __uninitialized_default_construct - inline namespace __cpo { -inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{}; +inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct{}; } // namespace __cpo // uninitialized_default_construct_n -namespace __uninitialized_default_construct_n { - -struct __fn { +struct __uninitialized_default_construct_n { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -79,17 +73,13 @@ struct __fn { } }; -} // namespace __uninitialized_default_construct_n - inline namespace __cpo { -inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{}; +inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n{}; } // namespace __cpo // uninitialized_value_construct -namespace __uninitialized_value_construct { - -struct __fn { +struct __uninitialized_value_construct { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { @@ -104,17 +94,13 @@ struct __fn { } }; -} // namespace __uninitialized_value_construct - inline namespace __cpo { -inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{}; +inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct{}; } // namespace __cpo // uninitialized_value_construct_n -namespace __uninitialized_value_construct_n { - -struct __fn { +struct __uninitialized_value_construct_n { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -124,17 +110,13 @@ struct __fn { } }; -} // namespace __uninitialized_value_construct_n - inline namespace __cpo { -inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{}; +inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n{}; } // namespace __cpo // uninitialized_fill -namespace __uninitialized_fill { - -struct __fn { +struct __uninitialized_fill { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp> requires constructible_from, const _Tp&> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { @@ -149,17 +131,13 @@ struct __fn { } }; -} // namespace __uninitialized_fill - inline namespace __cpo { -inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{}; +inline constexpr auto uninitialized_fill = __uninitialized_fill{}; } // namespace __cpo // uninitialized_fill_n -namespace __uninitialized_fill_n { - -struct __fn { +struct __uninitialized_fill_n { template <__nothrow_forward_iterator _ForwardIterator, class _Tp> requires constructible_from, const _Tp&> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -169,10 +147,8 @@ struct __fn { } }; -} // namespace __uninitialized_fill_n - inline namespace __cpo { -inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; +inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n{}; } // namespace __cpo // uninitialized_copy @@ -180,9 +156,7 @@ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; template using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_copy { - -struct __fn { +struct __uninitialized_copy { template _Sentinel1, __nothrow_forward_iterator _OutputIterator, @@ -207,10 +181,8 @@ struct __fn { } }; -} // namespace __uninitialized_copy - inline namespace __cpo { -inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; +inline constexpr auto uninitialized_copy = __uninitialized_copy{}; } // namespace __cpo // uninitialized_copy_n @@ -218,9 +190,7 @@ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; template using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_copy_n { - -struct __fn { +struct __uninitialized_copy_n { template _Sentinel> @@ -238,10 +208,8 @@ struct __fn { } }; -} // namespace __uninitialized_copy_n - inline namespace __cpo { -inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; +inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n{}; } // namespace __cpo // uninitialized_move @@ -249,9 +217,7 @@ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; template using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_move { - -struct __fn { +struct __uninitialized_move { template _Sentinel1, __nothrow_forward_iterator _OutputIterator, @@ -276,10 +242,8 @@ struct __fn { } }; -} // namespace __uninitialized_move - inline namespace __cpo { -inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; +inline constexpr auto uninitialized_move = __uninitialized_move{}; } // namespace __cpo // uninitialized_move_n @@ -287,9 +251,7 @@ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; template using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_move_n { - -struct __fn { +struct __uninitialized_move_n { template _Sentinel> @@ -308,10 +270,8 @@ struct __fn { } }; -} // namespace __uninitialized_move_n - inline namespace __cpo { -inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{}; +inline constexpr auto uninitialized_move_n = __uninitialized_move_n{}; } // namespace __cpo } // namespace ranges