-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++][ranges] LWG3618: Unnecessary iter_move
for transform_view::iterator
#91809
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
Conversation
@llvm/pr-subscribers-libcxx Author: Xiaoyang Liu (xiaoyang-sde) ChangesIntroductionThis patch implements LWG3618: Unnecessary
ReferenceFull diff: https://github.com/llvm/llvm-project/pull/91809.diff 2 Files Affected:
diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv
index 04f6e23375acd..55db4d209a407 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -146,7 +146,7 @@
"`3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","February 2022","","","|ranges|"
"`3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","February 2022","|Complete|","14.0","|format|"
"`3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","February 2022","",""
-"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","","","|ranges|"
+"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","|Complete|","19.0","|ranges|"
"`3619 <https://wg21.link/LWG3619>`__","Specification of ``vformat_to`` contains ill-formed ``formatted_size`` calls","February 2022","|Nothing to do|","","|format|"
"`3621 <https://wg21.link/LWG3621>`__","Remove feature-test macro ``__cpp_lib_monadic_optional`` ","February 2022","|Complete|","15.0"
"`3632 <https://wg21.link/LWG3632>`__","``unique_ptr`` ""Mandates: This constructor is not selected by class template argument deduction""","February 2022","|Nothing to do|",""
diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h
index dc3aaa59ed8c3..bcce389c0e680 100644
--- a/libcxx/include/__ranges/transform_view.h
+++ b/libcxx/include/__ranges/transform_view.h
@@ -326,13 +326,6 @@ class transform_view<_View, _Fn>::__iterator : public __transform_view_iterator_
{
return __x.__current_ - __y.__current_;
}
-
- _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __i) noexcept(noexcept(*__i)) {
- if constexpr (is_lvalue_reference_v<decltype(*__i)>)
- return std::move(*__i);
- else
- return *__i;
- }
};
# if _LIBCPP_STD_VER >= 23
|
@@ -146,7 +146,7 @@ | |||
"`3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","February 2022","","","|ranges|" | |||
"`3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","February 2022","|Complete|","14.0","|format|" | |||
"`3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","February 2022","","" | |||
"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","","","|ranges|" | |||
"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","|Complete|","19.0","|ranges|" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LWG-issues adds a noexcept
. This is not tested in libcxx/test/std/ranges/range.adaptors/range.transform/iterator/deref.pass.cpp
. Please update this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gentle ping, it looks like there is outstanding feedback that needs to be addressed.
@@ -37,7 +37,7 @@ int main(int, char**) { | |||
using View = std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>; | |||
View transformView(MoveOnlyView{buff}, PlusOneNoexcept{}); | |||
assert(*transformView.begin() == 1); | |||
LIBCPP_ASSERT_NOEXCEPT(*std::declval<std::ranges::iterator_t<View>>()); | |||
ASSERT_NOEXCEPT(*std::declval<std::ranges::iterator_t<View>>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The operator*
previously provided a noexcept
specifier as a libc++ extension. Following the adoption of this LWG issue, the noexcept
specifier is now standard behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying with your comment. LGTM!
Could you please merge this patch? Thank you! |
…::iterator` (#91809) Summary: ## Introduction This patch implements LWG3618: Unnecessary `iter_move` for `transform_view::iterator`. `transform_view`'s iterator currently specifies a customization point for `iter_move`. This customization point does the same thing that the default implementation would do, but its sole purpose is to ensure the appropriate conditional `noexcept` specification. ## Reference - [[range.transform.iterator]](https://eel.is/c++draft/range.transform.iterator) - [LWG3618](https://cplusplus.github.io/LWG/issue3618) Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251361
Introduction
This patch implements LWG3618: Unnecessary
iter_move
fortransform_view::iterator
.transform_view
's iterator currently specifies a customization point foriter_move
. This customization point does the same thing that the default implementation would do, but its sole purpose is to ensure the appropriate conditionalnoexcept
specification.Reference