[libcxx-commits] [PATCH] D120417: [libc++] [ranges] Regression test for decltype(auto) ranges::iter_move

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 23 10:32:44 PST 2022


Quuxplusone updated this revision to Diff 410862.
Quuxplusone added a comment.

Riiight. Actually use a projection type with non-external linkage, this time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120417/new/

https://reviews.llvm.org/D120417

Files:
  libcxx/test/std/iterators/iterator.requirements/indirectcallable/projected/projected.compile.pass.cpp


Index: libcxx/test/std/iterators/iterator.requirements/indirectcallable/projected/projected.compile.pass.cpp
===================================================================
--- libcxx/test/std/iterators/iterator.requirements/indirectcallable/projected/projected.compile.pass.cpp
+++ libcxx/test/std/iterators/iterator.requirements/indirectcallable/projected/projected.compile.pass.cpp
@@ -23,6 +23,27 @@
 static_assert(std::same_as<decltype(*std::declval<IntPtr>()), int const&>);
 static_assert(std::same_as<std::iter_difference_t<IntPtr>, std::ptrdiff_t>);
 
+void test() {
+  {
+    auto projection = [](int x) { return x + 1; };
+    using P = std::projected<int*, decltype(projection)>;
+    static_assert(std::same_as<std::iter_value_t<P>, int>);
+    static_assert(std::same_as<std::iter_reference_t<P>, int>);
+    static_assert(std::same_as<std::iter_difference_t<P>, std::ptrdiff_t>);
+    static_assert(std::same_as<std::iter_rvalue_reference_t<P>, int>);
+    static_assert(std::same_as<std::iter_common_reference_t<P>, int>);
+  }
+  {
+    auto projection = [](int& x) -> int& { return x; };
+    using P = std::projected<int*, decltype(projection)>;
+    static_assert(std::same_as<std::iter_value_t<P>, int>);
+    static_assert(std::same_as<std::iter_reference_t<P>, int&>);
+    static_assert(std::same_as<std::iter_difference_t<P>, std::ptrdiff_t>);
+    static_assert(std::same_as<std::iter_rvalue_reference_t<P>, int&&>);
+    static_assert(std::same_as<std::iter_common_reference_t<P>, int&>);
+  }
+}
+
 struct S { };
 
 using Cpp17InputIterator = std::projected<cpp17_input_iterator<S*>, int S::*>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120417.410862.patch
Type: text/x-patch
Size: 1627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220223/0dde674f/attachment.bin>


More information about the libcxx-commits mailing list