Skip to content

Commit 2629ae0

Browse files
committed
[libcxx] removes dedicated namespaces for ranges stuff
I originally put implementation-detail function objects into individual namespaces for `std::ranges` without a good reason for doing so. This practice was continued after I left libc++, 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.
1 parent 5c37e71 commit 2629ae0

File tree

94 files changed

+247
-567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+247
-567
lines changed

libcxx/include/__algorithm/ranges_adjacent_find.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
3232
_LIBCPP_BEGIN_NAMESPACE_STD
3333

3434
namespace ranges {
35-
namespace __adjacent_find {
36-
struct __fn {
35+
struct __adjacent_find {
3736
template <class _Iter, class _Sent, class _Proj, class _Pred>
3837
_LIBCPP_HIDE_FROM_ABI constexpr static _Iter
3938
__adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
@@ -67,10 +66,9 @@ struct __fn {
6766
return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
6867
}
6968
};
70-
} // namespace __adjacent_find
7169

7270
inline namespace __cpo {
73-
inline constexpr auto adjacent_find = __adjacent_find::__fn{};
71+
inline constexpr auto adjacent_find = __adjacent_find{};
7472
} // namespace __cpo
7573
} // namespace ranges
7674

libcxx/include/__algorithm/ranges_all_of.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

2929
namespace ranges {
30-
namespace __all_of {
31-
struct __fn {
30+
struct __all_of {
3231
template <class _Iter, class _Sent, class _Proj, class _Pred>
3332
_LIBCPP_HIDE_FROM_ABI constexpr static bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
3433
for (; __first != __last; ++__first) {
@@ -55,10 +54,9 @@ struct __fn {
5554
return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5655
}
5756
};
58-
} // namespace __all_of
5957

6058
inline namespace __cpo {
61-
inline constexpr auto all_of = __all_of::__fn{};
59+
inline constexpr auto all_of = __all_of{};
6260
} // namespace __cpo
6361
} // namespace ranges
6462

libcxx/include/__algorithm/ranges_any_of.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

2929
namespace ranges {
30-
namespace __any_of {
31-
struct __fn {
30+
struct __any_of {
3231
template <class _Iter, class _Sent, class _Proj, class _Pred>
3332
_LIBCPP_HIDE_FROM_ABI constexpr static bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
3433
for (; __first != __last; ++__first) {
@@ -55,10 +54,9 @@ struct __fn {
5554
return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5655
}
5756
};
58-
} // namespace __any_of
5957

6058
inline namespace __cpo {
61-
inline constexpr auto any_of = __any_of::__fn{};
59+
inline constexpr auto any_of = __any_of{};
6260
} // namespace __cpo
6361
} // namespace ranges
6462

libcxx/include/__algorithm/ranges_binary_search.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
_LIBCPP_BEGIN_NAMESPACE_STD
3030

3131
namespace ranges {
32-
namespace __binary_search {
33-
struct __fn {
32+
struct __binary_search {
3433
template <forward_iterator _Iter,
3534
sentinel_for<_Iter> _Sent,
3635
class _Type,
@@ -54,10 +53,9 @@ struct __fn {
5453
return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret));
5554
}
5655
};
57-
} // namespace __binary_search
5856

5957
inline namespace __cpo {
60-
inline constexpr auto binary_search = __binary_search::__fn{};
58+
inline constexpr auto binary_search = __binary_search{};
6159
} // namespace __cpo
6260
} // namespace ranges
6361

libcxx/include/__algorithm/ranges_clamp.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

2929
namespace ranges {
30-
namespace __clamp {
31-
struct __fn {
30+
struct __clamp {
3231
template <class _Type,
3332
class _Proj = identity,
3433
indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
@@ -46,10 +45,9 @@ struct __fn {
4645
return __value;
4746
}
4847
};
49-
} // namespace __clamp
5048

5149
inline namespace __cpo {
52-
inline constexpr auto clamp = __clamp::__fn{};
50+
inline constexpr auto clamp = __clamp{};
5351
} // namespace __cpo
5452
} // namespace ranges
5553

libcxx/include/__algorithm/ranges_contains.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
_LIBCPP_BEGIN_NAMESPACE_STD
3131

3232
namespace ranges {
33-
namespace __contains {
34-
struct __fn {
33+
struct __contains {
3534
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3635
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
3736
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool static
@@ -47,10 +46,9 @@ struct __fn {
4746
ranges::end(__range);
4847
}
4948
};
50-
} // namespace __contains
5149

5250
inline namespace __cpo {
53-
inline constexpr auto contains = __contains::__fn{};
51+
inline constexpr auto contains = __contains{};
5452
} // namespace __cpo
5553
} // namespace ranges
5654

libcxx/include/__algorithm/ranges_copy.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ namespace ranges {
3434
template <class _InIter, class _OutIter>
3535
using copy_result = in_out_result<_InIter, _OutIter>;
3636

37-
namespace __copy {
38-
struct __fn {
37+
struct __copy {
3938
template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
4039
requires indirectly_copyable<_InIter, _OutIter>
4140
_LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter>
@@ -52,10 +51,9 @@ struct __fn {
5251
return {std::move(__ret.first), std::move(__ret.second)};
5352
}
5453
};
55-
} // namespace __copy
5654

5755
inline namespace __cpo {
58-
inline constexpr auto copy = __copy::__fn{};
56+
inline constexpr auto copy = __copy{};
5957
} // namespace __cpo
6058
} // namespace ranges
6159

libcxx/include/__algorithm/ranges_copy_backward.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ namespace ranges {
3232
template <class _Ip, class _Op>
3333
using copy_backward_result = in_out_result<_Ip, _Op>;
3434

35-
namespace __copy_backward {
36-
struct __fn {
35+
struct __copy_backward {
3736
template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>
3837
requires indirectly_copyable<_InIter1, _InIter2>
3938
_LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2>
@@ -50,10 +49,9 @@ struct __fn {
5049
return {std::move(__ret.first), std::move(__ret.second)};
5150
}
5251
};
53-
} // namespace __copy_backward
5452

5553
inline namespace __cpo {
56-
inline constexpr auto copy_backward = __copy_backward::__fn{};
54+
inline constexpr auto copy_backward = __copy_backward{};
5755
} // namespace __cpo
5856
} // namespace ranges
5957

libcxx/include/__algorithm/ranges_copy_if.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ namespace ranges {
3333
template <class _Ip, class _Op>
3434
using copy_if_result = in_out_result<_Ip, _Op>;
3535

36-
namespace __copy_if {
37-
struct __fn {
36+
struct __copy_if {
3837
template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
3938
_LIBCPP_HIDE_FROM_ABI static constexpr copy_if_result<_InIter, _OutIter>
4039
__copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
@@ -68,10 +67,9 @@ struct __fn {
6867
return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
6968
}
7069
};
71-
} // namespace __copy_if
7270

7371
inline namespace __cpo {
74-
inline constexpr auto copy_if = __copy_if::__fn{};
72+
inline constexpr auto copy_if = __copy_if{};
7573
} // namespace __cpo
7674
} // namespace ranges
7775

libcxx/include/__algorithm/ranges_copy_n.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ namespace ranges {
3434
template <class _Ip, class _Op>
3535
using copy_n_result = in_out_result<_Ip, _Op>;
3636

37-
namespace __copy_n {
38-
struct __fn {
37+
struct __copy_n {
3938
template <class _InIter, class _DiffType, class _OutIter>
4039
_LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>
4140
__go(_InIter __first, _DiffType __n, _OutIter __result) {
@@ -62,10 +61,9 @@ struct __fn {
6261
return __go(std::move(__first), __n, std::move(__result));
6362
}
6463
};
65-
} // namespace __copy_n
6664

6765
inline namespace __cpo {
68-
inline constexpr auto copy_n = __copy_n::__fn{};
66+
inline constexpr auto copy_n = __copy_n{};
6967
} // namespace __cpo
7068
} // namespace ranges
7169

libcxx/include/__algorithm/ranges_count.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
_LIBCPP_BEGIN_NAMESPACE_STD
3232

3333
namespace ranges {
34-
namespace __count {
35-
struct __fn {
34+
struct __count {
3635
template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3736
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
3837
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
@@ -47,10 +46,9 @@ struct __fn {
4746
return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj);
4847
}
4948
};
50-
} // namespace __count
5149

5250
inline namespace __cpo {
53-
inline constexpr auto count = __count::__fn{};
51+
inline constexpr auto count = __count{};
5452
} // namespace __cpo
5553
} // namespace ranges
5654

libcxx/include/__algorithm/ranges_count_if.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ __count_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
4141
return __counter;
4242
}
4343

44-
namespace __count_if {
45-
struct __fn {
44+
struct __count_if {
4645
template <input_iterator _Iter,
4746
sentinel_for<_Iter> _Sent,
4847
class _Proj = identity,
@@ -60,10 +59,9 @@ struct __fn {
6059
return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
6160
}
6261
};
63-
} // namespace __count_if
6462

6563
inline namespace __cpo {
66-
inline constexpr auto count_if = __count_if::__fn{};
64+
inline constexpr auto count_if = __count_if{};
6765
} // namespace __cpo
6866
} // namespace ranges
6967

libcxx/include/__algorithm/ranges_ends_with.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
_LIBCPP_BEGIN_NAMESPACE_STD
3434

3535
namespace ranges {
36-
namespace __ends_with {
37-
struct __fn {
36+
struct __ends_with {
3837
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
3938
static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional(
4039
_Iter1 __first1,
@@ -182,10 +181,9 @@ struct __fn {
182181
}
183182
}
184183
};
185-
} // namespace __ends_with
186184

187185
inline namespace __cpo {
188-
inline constexpr auto ends_with = __ends_with::__fn{};
186+
inline constexpr auto ends_with = __ends_with{};
189187
} // namespace __cpo
190188
} // namespace ranges
191189

libcxx/include/__algorithm/ranges_equal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
_LIBCPP_BEGIN_NAMESPACE_STD
3232

3333
namespace ranges {
34-
namespace __equal {
35-
struct __fn {
34+
struct __equal {
3635
template <input_iterator _Iter1,
3736
sentinel_for<_Iter1> _Sent1,
3837
input_iterator _Iter2,
@@ -90,10 +89,9 @@ struct __fn {
9089
return false;
9190
}
9291
};
93-
} // namespace __equal
9492

9593
inline namespace __cpo {
96-
inline constexpr auto equal = __equal::__fn{};
94+
inline constexpr auto equal = __equal{};
9795
} // namespace __cpo
9896
} // namespace ranges
9997

libcxx/include/__algorithm/ranges_equal_range.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
_LIBCPP_BEGIN_NAMESPACE_STD
3636

3737
namespace ranges {
38-
namespace __equal_range {
39-
40-
struct __fn {
38+
struct __equal_range {
4139
template <forward_iterator _Iter,
4240
sentinel_for<_Iter> _Sent,
4341
class _Tp,
@@ -61,10 +59,8 @@ struct __fn {
6159
}
6260
};
6361

64-
} // namespace __equal_range
65-
6662
inline namespace __cpo {
67-
inline constexpr auto equal_range = __equal_range::__fn{};
63+
inline constexpr auto equal_range = __equal_range{};
6864
} // namespace __cpo
6965
} // namespace ranges
7066

libcxx/include/__algorithm/ranges_fill.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
_LIBCPP_BEGIN_NAMESPACE_STD
2626

2727
namespace ranges {
28-
namespace __fill {
29-
struct __fn {
28+
struct __fill {
3029
template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent>
3130
_LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const {
3231
if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {
@@ -43,10 +42,9 @@ struct __fn {
4342
return (*this)(ranges::begin(__range), ranges::end(__range), __value);
4443
}
4544
};
46-
} // namespace __fill
4745

4846
inline namespace __cpo {
49-
inline constexpr auto fill = __fill::__fn{};
47+
inline constexpr auto fill = __fill{};
5048
} // namespace __cpo
5149
} // namespace ranges
5250

libcxx/include/__algorithm/ranges_fill_n.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
_LIBCPP_BEGIN_NAMESPACE_STD
2323

2424
namespace ranges {
25-
namespace __fill_n {
26-
struct __fn {
25+
struct __fill_n {
2726
template <class _Type, output_iterator<const _Type&> _Iter>
2827
_LIBCPP_HIDE_FROM_ABI constexpr _Iter
2928
operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const {
@@ -34,10 +33,9 @@ struct __fn {
3433
return __first;
3534
}
3635
};
37-
} // namespace __fill_n
3836

3937
inline namespace __cpo {
40-
inline constexpr auto fill_n = __fill_n::__fn{};
38+
inline constexpr auto fill_n = __fill_n{};
4139
} // namespace __cpo
4240
} // namespace ranges
4341

libcxx/include/__algorithm/ranges_find.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
_LIBCPP_BEGIN_NAMESPACE_STD
3434

3535
namespace ranges {
36-
namespace __find {
37-
struct __fn {
36+
struct __find {
3837
template <class _Iter, class _Sent, class _Tp, class _Proj>
3938
_LIBCPP_HIDE_FROM_ABI static constexpr _Iter
4039
__find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
@@ -61,10 +60,9 @@ struct __fn {
6160
return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);
6261
}
6362
};
64-
} // namespace __find
6563

6664
inline namespace __cpo {
67-
inline constexpr auto find = __find::__fn{};
65+
inline constexpr auto find = __find{};
6866
} // namespace __cpo
6967
} // namespace ranges
7068

0 commit comments

Comments
 (0)