[libcxx-commits] [libcxx] 87451cf - [libc++] Partly addresses LWG3798.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 31 11:00:46 PST 2023
Author: Mark de Wever
Date: 2023-01-31T20:00:40+01:00
New Revision: 87451cf05a0fb96b38cb73dd4a13b8566cca73e9
URL: https://github.com/llvm/llvm-project/commit/87451cf05a0fb96b38cb73dd4a13b8566cca73e9
DIFF: https://github.com/llvm/llvm-project/commit/87451cf05a0fb96b38cb73dd4a13b8566cca73e9.diff
LOG: [libc++] Partly addresses LWG3798.
LWG3798 Rvalue reference and iterator_category
The changes are only applied to `ranges::transform_view`, the other
views haven't been implemented yet.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D142815
Added:
Modified:
libcxx/docs/Status/Cxx2b.rst
libcxx/docs/Status/Cxx2bIssues.csv
libcxx/include/__iterator/iterator_traits.h
libcxx/include/__ranges/transform_view.h
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
libcxx/test/std/ranges/range.adaptors/range.transform/iterator/types.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx2b.rst b/libcxx/docs/Status/Cxx2b.rst
index e79ed285c644d..b50792a2143cc 100644
--- a/libcxx/docs/Status/Cxx2b.rst
+++ b/libcxx/docs/Status/Cxx2b.rst
@@ -52,3 +52,7 @@ Library Working Group Issues Status
:file: Cxx2bIssues.csv
:header-rows: 1
:widths: auto
+
+.. note::
+
+ .. [#note-LWG3798] LWG3798: ``join_with_view``, ``zip_transform_view``, and ``adjacent_transform_view`` haven't been done yet since these types aren't implemented yet.
diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv
index 0dd84d7d8f273..b286ad3d6b357 100644
--- a/libcxx/docs/Status/Cxx2bIssues.csv
+++ b/libcxx/docs/Status/Cxx2bIssues.csv
@@ -234,7 +234,7 @@
"`3792 <https://wg21.link/LWG3792>`__","``__cpp_lib_constexpr_algorithms`` should also be defined in ``<utility>``", "November 2022","|Complete|","16.0",""
"`3795 <https://wg21.link/LWG3795>`__","Self-move-assignment of ``std::future`` and ``std::shared_future`` have unimplementable postconditions", "November 2022","","",""
"`3796 <https://wg21.link/LWG3796>`__","``movable-box`` as member should use ``default-initialization`` instead of ``copy-initialization``", "November 2022","","","|ranges|"
-"`3798 <https://wg21.link/LWG3798>`__","Rvalue reference and ``iterator_category``", "November 2022","","",""
+"`3798 <https://wg21.link/LWG3798>`__","Rvalue reference and ``iterator_category``", "November 2022","|Partial| [#note-LWG3798]_","","|ranges|"
"`3801 <https://wg21.link/LWG3801>`__","``cartesian_product_view::iterator::distance-from`` ignores the size of last underlying range", "November 2022","","","|ranges|"
"`3814 <https://wg21.link/LWG3814>`__","Add freestanding items requested by NB comments", "November 2022","","",""
"`3816 <https://wg21.link/LWG3816>`__","``flat_map`` and ``flat_multimap`` should impose sequence container requirements", "November 2022","","","|flat_containers|"
diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h
index c9d8944bfee32..c67d4590b46d1 100644
--- a/libcxx/include/__iterator/iterator_traits.h
+++ b/libcxx/include/__iterator/iterator_traits.h
@@ -190,7 +190,7 @@ template<class _Ip>
concept __cpp17_forward_iterator =
__cpp17_input_iterator<_Ip> &&
constructible_from<_Ip> &&
- is_lvalue_reference_v<iter_reference_t<_Ip>> &&
+ is_reference_v<iter_reference_t<_Ip>> &&
same_as<remove_cvref_t<iter_reference_t<_Ip>>,
typename indirectly_readable_traits<_Ip>::value_type> &&
requires(_Ip __i) {
diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h
index 66d9e80e6e61b..ebdff77a7fec6 100644
--- a/libcxx/include/__ranges/transform_view.h
+++ b/libcxx/include/__ranges/transform_view.h
@@ -166,7 +166,7 @@ struct __transform_view_iterator_category_base<_View, _Fn> {
using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;
using iterator_category = conditional_t<
- is_lvalue_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>,
+ is_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>,
conditional_t<
derived_from<_Cat, contiguous_iterator_tag>,
random_access_iterator_tag,
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
index 7ba8c7587ad1d..0b8dd9f469cd5 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
@@ -72,7 +72,7 @@ static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::back_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::front_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::insert_iterator<std::vector<int>>>);
-static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::move_iterator<int*>>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::list<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
index 7a2000a7634f0..b92b572fcb12c 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
@@ -72,7 +72,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::forwa
static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::back_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::front_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::insert_iterator<std::vector<int>>>);
-static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::move_iterator<int*>>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::list<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
index ddbf60f930499..f4adb6afb1e67 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
@@ -72,7 +72,7 @@ static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::back_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::front_insert_iterator<std::vector<int>>>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::insert_iterator<std::vector<int>>>);
-static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::move_iterator<int*>>);
+static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::move_iterator<int*>>);
// <list>
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::list<int>::iterator>);
diff --git a/libcxx/test/std/ranges/range.adaptors/range.transform/iterator/types.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.transform/iterator/types.pass.cpp
index 2c095d8528f87..25d8936f4e4eb 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.transform/iterator/types.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.transform/iterator/types.pass.cpp
@@ -43,6 +43,15 @@ constexpr bool test() {
static_assert(std::same_as<typename TIter::value_type, int>);
static_assert(std::same_as<typename TIter::
diff erence_type, std::ptr
diff _t>);
}
+ {
+ // Member typedefs for random access iterator, LWG3798 rvalue reference.
+ using TView = std::ranges::transform_view<RandomAccessView, IncrementRvalueRef>;
+ using TIter = std::ranges::iterator_t<TView>;
+ static_assert(std::same_as<typename TIter::iterator_concept, std::random_access_iterator_tag>);
+ static_assert(std::same_as<typename TIter::iterator_category, std::random_access_iterator_tag>);
+ static_assert(std::same_as<typename TIter::value_type, int>);
+ static_assert(std::same_as<typename TIter::
diff erence_type, std::ptr
diff _t>);
+ }
{
// Member typedefs for random access iterator/not-lvalue-ref.
using TView = std::ranges::transform_view<RandomAccessView, PlusOneMutable>;
More information about the libcxx-commits
mailing list