[libcxx-commits] [PATCH] D141216: [libc++][test] Fix common_input_iterator

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 7 23:12:11 PST 2023


CaseyCarter created this revision.
CaseyCarter added a reviewer: huixie90.
CaseyCarter added a project: libc++.
Herald added a project: All.
CaseyCarter requested review of this revision.
Herald added a reviewer: libc++.

The reference type of `common_input_iterator<const int*>` can't be `int&`, because an lvalue of type `const int` _can't_ bind to an `int&`. Fix by changing the return type of `operator*` to `auto&` since the template is currently only used with `int*` and `const int*` arguments.

I'm not sure why this break the tests with MSVCSTL `zip_view` and not libc++ `zip_view`, but it does.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141216

Files:
  libcxx/test/std/ranges/range.adaptors/range.zip/types.h


Index: libcxx/test/std/ranges/range.adaptors/range.zip/types.h
===================================================================
--- libcxx/test/std/ranges/range.adaptors/range.zip/types.h
+++ libcxx/test/std/ranges/range.adaptors/range.zip/types.h
@@ -319,7 +319,7 @@
   }
   constexpr void operator++(int) { ++it_; }
 
-  constexpr int& operator*() const { return *it_; }
+  constexpr auto& operator*() const { return *it_; }
 
   friend constexpr bool operator==(common_input_iterator const&, common_input_iterator const&) = default;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141216.487144.patch
Type: text/x-patch
Size: 543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230108/ccd56d81/attachment-0001.bin>


More information about the libcxx-commits mailing list