Skip to content

Commit e776610

Browse files
committed
changes to using static opertaor()
1 parent b373740 commit e776610

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

libcxx/include/__algorithm/fold.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ concept __indirectly_binary_left_foldable =
6363

6464
struct __fold_left_with_iter {
6565
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
66-
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto
67-
operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) const {
66+
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
67+
operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
6868
using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
6969

7070
if (__first == __last) {
@@ -80,8 +80,8 @@ struct __fold_left_with_iter {
8080
}
8181

8282
template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
83-
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) const {
84-
auto __result = (*this)(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f));
83+
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
84+
auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f));
8585

8686
using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>;
8787
return fold_left_with_iter_result<borrowed_iterator_t<_Rp>, _Up>{
@@ -95,13 +95,13 @@ inline constexpr auto fold_left_with_iter = __fold_left_with_iter();
9595

9696
struct __fold_left {
9797
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
98-
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto
99-
operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) const {
98+
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
99+
operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
100100
return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).result;
101101
}
102102

103103
template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
104-
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) const {
104+
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
105105
return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).result;
106106
}
107107
};

libcxx/modules/std/algorithm.inc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export namespace std {
1616
using std::ranges::in_in_result;
1717
using std::ranges::in_out_out_result;
1818
using std::ranges::in_out_result;
19-
// using std::ranges::in_value_result;
19+
using std::ranges::in_value_result;
2020
using std::ranges::min_max_result;
2121
// using std::ranges::out_value_result;
2222
} // namespace ranges
@@ -48,6 +48,12 @@ export namespace std {
4848
} // namespace ranges
4949
#endif
5050

51+
// [alg.fold], fold
52+
namespace ranges {
53+
using std::ranges::fold_left;
54+
using std::ranges::fold_left_with_iter;
55+
} // namespace ranges
56+
5157
// [alg.foreach], for each
5258
using std::for_each;
5359

0 commit comments

Comments
 (0)