Skip to content

Commit

Permalink
Update range_adaptor.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lackhole committed Aug 18, 2024
1 parent 417cbb9 commit 8343468
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/preview/__ranges/range_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ class range_adaptor : public range_adaptor_closure<range_adaptor<Niebloid, Args.

template<typename R, std::enable_if_t<is_invocable<Niebloid, R, Args&...>::value, int> = 0>
constexpr decltype(auto) operator()(R&& r) & {
return call(*this, std::forward<R>(r), std::index_sequence_for<Args...>{});
return call(std::forward<R>(r), args_, std::index_sequence_for<Args...>{});
}

template<typename R, std::enable_if_t<is_invocable<Niebloid, R, const Args&...>::value, int> = 0>
constexpr decltype(auto) operator()(R&& r) const & {
return call(*this, std::forward<R>(r), std::index_sequence_for<Args...>{});
return call(std::forward<R>(r), args_, std::index_sequence_for<Args...>{});
}

template<typename R, std::enable_if_t<is_invocable<Niebloid, R, Args&&...>::value, int> = 0>
constexpr decltype(auto) operator()(R&& r) && {
return call(std::move(*this), std::forward<R>(r), std::index_sequence_for<Args...>{});
return call(std::forward<R>(r), std::move(args_), std::index_sequence_for<Args...>{});
}

template<typename R, std::enable_if_t<is_invocable<Niebloid, R, const Args&&...>::value, int> = 0>
constexpr decltype(auto) operator()(R&& r) const && {
return call(std::move(*this), std::forward<R>(r), std::index_sequence_for<Args...>{});
return call(std::forward<R>(r), std::move(args_), std::index_sequence_for<Args...>{});
}

private:
template<typename This, typename R, std::size_t... I>
static constexpr decltype(auto) call(This&& thiz, R&& r, std::index_sequence<I...>) {
return Niebloid{}(std::forward<R>(r), std::get<I>(std::forward<This>(thiz).args_)...);
template<typename ArgTuple, typename R, std::size_t... I>
static constexpr decltype(auto) call(R&& r, ArgTuple&& tuple, std::index_sequence<I...>) {
return Niebloid{}(std::forward<R>(r), std::get<I>(std::forward<ArgTuple>(tuple))...);
}

std::tuple<Args...> args_;
Expand Down

0 comments on commit 8343468

Please sign in to comment.