[libcxx-commits] [PATCH] D108575: [libcxx] Define insert_iterator::iter with ranges::iterator_t

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 23 12:52:31 PDT 2021


jloser created this revision.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

`insert_iterator::iter` member object is defined as `Container::iterator` but
the standard requires `iter` to be defined in terms of `ranges::iterator_t` as
of C++20.  So, if in C++20 or later, define `iter` member object as
`ranges::iterator_t`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108575

Files:
  libcxx/include/__iterator/insert_iterator.h


Index: libcxx/include/__iterator/insert_iterator.h
===================================================================
--- libcxx/include/__iterator/insert_iterator.h
+++ libcxx/include/__iterator/insert_iterator.h
@@ -17,6 +17,10 @@
 #include <__utility/move.h>
 #include <cstddef>
 
+#if _LIBCPP_STD_VER > 17
+#include <__ranges/access.h>
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -36,8 +40,12 @@
 _LIBCPP_SUPPRESS_DEPRECATED_POP
 protected:
     _Container* container;
-    typename _Container::iterator iter; // FIXME: `ranges::iterator_t<Container>` in C++20 mode
-public:
+#if _LIBCPP_STD_VER > 17
+    ranges::iterator_t<_Container> iter;
+#else
+    typename _Container::iterator iter;
+#endif
+  public:
     typedef output_iterator_tag iterator_category;
     typedef void value_type;
 #if _LIBCPP_STD_VER > 17


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108575.368182.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210823/5154e586/attachment.bin>


More information about the libcxx-commits mailing list