[libcxx-commits] [PATCH] D101404: [libcxx] Fix __wrap_iter to work with to_address.
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 27 15:29:40 PDT 2021
zoecarver created this revision.
zoecarver added reviewers: cjdb, ldionne, Quuxplusone, EricWF.
zoecarver requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This is required for contiguous_iterator. This will make __wrap_iter a contiguous_iterator when it needs to be which will fix types such as std::string and std::vector.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101404
Files:
libcxx/include/iterator
libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
Index: libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
+++ libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
@@ -14,7 +14,10 @@
// template <class Ptr> constexpr auto to_address(const Ptr& p) noexcept;
#include <memory>
+
#include <cassert>
+#include <vector>
+
#include "test_macros.h"
class P1
@@ -122,5 +125,9 @@
int main(int, char**) {
test();
static_assert(test());
+
+ std::vector vec = {1, 2, 3};
+ assert(std::to_address(vec.begin()) == vec.data());
+
return 0;
}
Index: libcxx/include/iterator
===================================================================
--- libcxx/include/iterator
+++ libcxx/include/iterator
@@ -1277,6 +1277,7 @@
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef typename iterator_traits<iterator_type>::pointer pointer;
+ typedef typename pointer_traits<pointer>::element_type element_type;
typedef typename iterator_traits<iterator_type>::reference reference;
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
#if _LIBCPP_STD_VER > 17
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101404.341003.patch
Type: text/x-patch
Size: 1401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210427/512fabb7/attachment-0001.bin>
More information about the libcxx-commits
mailing list