-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Rename __range_adaptor_closure_t #110886
Open
ldionne
wants to merge
1
commit into
llvm:main
Choose a base branch
from
ldionne:review/rename-range_adaptor_closure_t
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+16
−20
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The name __range_adaptor_closure_t can easily be confused with __range_adaptor_closure, so something more distinct is preferable. Fixes llvm#67611
llvmbot
added
the
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
label
Oct 2, 2024
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesThe name __range_adaptor_closure_t can easily be confused with __range_adaptor_closure, so something more distinct is preferable. Fixes #67611 Full diff: https://github.com/llvm/llvm-project/pull/110886.diff 11 Files Affected:
diff --git a/libcxx/include/__ranges/chunk_by_view.h b/libcxx/include/__ranges/chunk_by_view.h
index 00014d9f10ae88..e4df589bc286f7 100644
--- a/libcxx/include/__ranges/chunk_by_view.h
+++ b/libcxx/include/__ranges/chunk_by_view.h
@@ -215,7 +215,7 @@ struct __fn {
requires constructible_from<decay_t<_Pred>, _Pred>
[[nodiscard]] _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)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
}
};
} // namespace __chunk_by
diff --git a/libcxx/include/__ranges/drop_view.h b/libcxx/include/__ranges/drop_view.h
index 853e22a402cad1..bd66371f4ed218 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -307,7 +307,7 @@ struct __fn {
requires constructible_from<decay_t<_Np>, _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const
noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n)));
}
};
diff --git a/libcxx/include/__ranges/drop_while_view.h b/libcxx/include/__ranges/drop_while_view.h
index 92f48bd0ecfba3..6413ff52bc0e01 100644
--- a/libcxx/include/__ranges/drop_while_view.h
+++ b/libcxx/include/__ranges/drop_while_view.h
@@ -115,7 +115,7 @@ struct __fn {
requires constructible_from<decay_t<_Pred>, _Pred>
[[nodiscard]] _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)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
}
};
diff --git a/libcxx/include/__ranges/filter_view.h b/libcxx/include/__ranges/filter_view.h
index 5b938dd4c16e19..22f67b2d967d56 100644
--- a/libcxx/include/__ranges/filter_view.h
+++ b/libcxx/include/__ranges/filter_view.h
@@ -239,7 +239,7 @@ struct __fn {
requires constructible_from<decay_t<_Pred>, _Pred>
[[nodiscard]] _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)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
}
};
} // namespace __filter
diff --git a/libcxx/include/__ranges/lazy_split_view.h b/libcxx/include/__ranges/lazy_split_view.h
index db031fe5f8b49b..0dcbc134a21f26 100644
--- a/libcxx/include/__ranges/lazy_split_view.h
+++ b/libcxx/include/__ranges/lazy_split_view.h
@@ -420,7 +420,7 @@ struct __fn {
requires constructible_from<decay_t<_Pattern>, _Pattern>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
}
};
} // namespace __lazy_split_view
diff --git a/libcxx/include/__ranges/range_adaptor.h b/libcxx/include/__ranges/range_adaptor.h
index b20165319bc351..d944a83406ba7f 100644
--- a/libcxx/include/__ranges/range_adaptor.h
+++ b/libcxx/include/__ranges/range_adaptor.h
@@ -47,15 +47,15 @@ namespace ranges {
// - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))`
template <class _Tp>
requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
-struct __range_adaptor_closure;
+struct __range_adaptor_closure {};
// Type that wraps an arbitrary function object and makes it into a range adaptor closure,
// i.e. something that can be called via the `x | f` notation.
template <class _Fn>
-struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
- _LIBCPP_HIDE_FROM_ABI constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) {}
+struct __pipeable : _Fn, __range_adaptor_closure<__pipeable<_Fn>> {
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __pipeable(_Fn&& __f) : _Fn(std::move(__f)) {}
};
-_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__pipeable);
template <class _Tp>
_Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);
@@ -79,13 +79,9 @@ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(
is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {
- return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
+ return __pipeable(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
}
-template <class _Tp>
- requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
-struct __range_adaptor_closure {};
-
# if _LIBCPP_STD_VER >= 23
template <class _Tp>
requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
diff --git a/libcxx/include/__ranges/split_view.h b/libcxx/include/__ranges/split_view.h
index ce3606aedfefb9..7527281905ffeb 100644
--- a/libcxx/include/__ranges/split_view.h
+++ b/libcxx/include/__ranges/split_view.h
@@ -211,7 +211,7 @@ struct __fn {
requires constructible_from<decay_t<_Pattern>, _Pattern>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
}
};
} // namespace __split_view
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 27ca8155a69b18..8e2d354b58a554 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -347,7 +347,7 @@ struct __fn {
requires constructible_from<decay_t<_Np>, _Np>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const
noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n)));
}
};
diff --git a/libcxx/include/__ranges/take_while_view.h b/libcxx/include/__ranges/take_while_view.h
index 77ea9f7bb81316..b7cb0aef58f114 100644
--- a/libcxx/include/__ranges/take_while_view.h
+++ b/libcxx/include/__ranges/take_while_view.h
@@ -149,7 +149,7 @@ struct __fn {
requires constructible_from<decay_t<_Pred>, _Pred>
[[nodiscard]] _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)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
}
};
diff --git a/libcxx/include/__ranges/to.h b/libcxx/include/__ranges/to.h
index e0abe6290b8f7d..85fc580b53c9bc 100644
--- a/libcxx/include/__ranges/to.h
+++ b/libcxx/include/__ranges/to.h
@@ -214,7 +214,7 @@ template <class _Container, class... _Args>
}
{ return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); };
- return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
+ return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
}
// Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template
@@ -233,7 +233,7 @@ template <template <class...> class _Container, class... _Args>
};
// clang-format on
- return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
+ return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
}
} // namespace ranges
diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h
index 42e9a131f73b15..0ce1bfe883500f 100644
--- a/libcxx/include/__ranges/transform_view.h
+++ b/libcxx/include/__ranges/transform_view.h
@@ -398,7 +398,7 @@ struct __fn {
requires constructible_from<decay_t<_Fn>, _Fn>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f) const
noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) {
- return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f)));
+ return __pipeable(std::__bind_back(*this, std::forward<_Fn>(__f)));
}
};
} // namespace __transform
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The name __range_adaptor_closure_t can easily be confused with __range_adaptor_closure, so something more distinct is preferable.
Fixes #67611