@@ -120,16 +120,36 @@ namespace stdsharp
120
120
return (*this )(std::ranges::cbegin (r), std::ranges::cend (r), in);
121
121
}
122
122
} is_iter_in{};
123
+ }
123
124
124
- inline constexpr struct index_fn
125
+ namespace stdsharp ::details
126
+ {
127
+ template <typename Fn>
128
+ struct index_fn
125
129
{
126
- template <typename R>
127
- requires std::invocable<::ranges::index_fn, R, std::ranges::range_size_t <R>>
128
- constexpr decltype (auto ) operator()(R&& r, const std::ranges::range_size_t <R>& i) const
130
+ template <typename R, typename ... Args>
131
+ constexpr decltype (auto ) operator()(
132
+ R&& r,
133
+ const std::ranges::range_difference_t <R>& i,
134
+ Args&&... args //
135
+ ) const
136
+ requires requires(std::invoke_result_t <Fn, R, decltype (i)> result) {
137
+ requires sizeof ...(Args) == 0 ||
138
+ std::invocable<index_fn, decltype (result), Args...>;
139
+ }
129
140
{
130
- return ::ranges::index (r, i);
141
+ auto && result = Fn{}(cpp_forward (r), i);
142
+ if constexpr (sizeof ...(Args) == 0 ) return result;
143
+ else return (*this )(cpp_forward (result), cpp_forward (args)...);
131
144
}
132
- } index{};
145
+ };
146
+ }
147
+
148
+ namespace stdsharp
149
+ {
150
+ inline constexpr details::index_fn<::ranges::index_fn> index{};
151
+
152
+ inline constexpr details::index_fn<::ranges::at_fn> index_at{};
133
153
}
134
154
135
155
namespace stdsharp ::views
0 commit comments