[libcxx-commits] [libcxx] [libc++][ranges] use `static operator()` for C++23 ranges (PR #86052)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 21 23:16:42 PDT 2024
================
@@ -205,17 +205,19 @@ namespace views {
namespace __chunk_by {
struct __fn {
template <class _Range, class _Pred>
- _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
- noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
- -> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
- return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(
+ _Range&& __range,
+ _Pred&& __pred) noexcept(noexcept(chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
+ -> decltype(/*-----------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
+ return /*------------------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
}
template <class _Pred>
requires constructible_from<decay_t<_Pred>, _Pred>
- _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
- noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ operator()(_Pred&& __pred) noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
+ constexpr auto __self = __fn{};
+ return __range_adaptor_closure_t(std::__bind_back(__self, std::forward<_Pred>(__pred)));
----------------
mordante wrote:
The `__bind_back` implementation detail is used C++20 so that "runs" into the same issue. I really want to avoid this change in this PR. We can make a separate PR where we add a `__bind_back` for C++23 which does that. However in that case I want to see a measurable performance improvement before adding that.
https://github.com/llvm/llvm-project/pull/86052
More information about the libcxx-commits
mailing list