[libcxx-commits] [PATCH] D122072: [libc++][test] Adds an cpp20_output_iterator.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 5 08:31:50 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83de10738244: [libc++][test] Adds an cpp20_output_iterator. (authored by Mordante).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122072/new/
https://reviews.llvm.org/D122072
Files:
libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.output/output_iterator.compile.pass.cpp
libcxx/test/support/test_iterators.h
Index: libcxx/test/support/test_iterators.h
===================================================================
--- libcxx/test/support/test_iterators.h
+++ libcxx/test/support/test_iterators.h
@@ -515,6 +515,32 @@
using type = std::iter_value_t<I>;
};
+template <class It>
+class cpp20_output_iterator {
+ It it_;
+
+public:
+ using difference_type = std::iter_difference_t<It>;
+
+ constexpr explicit cpp20_output_iterator(It it) : it_(it) {}
+ cpp20_output_iterator(cpp20_output_iterator&&) = default;
+ cpp20_output_iterator& operator=(cpp20_output_iterator&&) = default;
+
+ constexpr decltype(auto) operator*() const { return *it_; }
+ constexpr cpp20_output_iterator& operator++() {
+ ++it_;
+ return *this;
+ }
+ constexpr cpp20_output_iterator operator++(int) { return cpp20_output_iterator(it_++); }
+
+ friend constexpr It base(const cpp20_output_iterator& i) { return i.it_; }
+
+ template <class T>
+ void operator,(T const&) = delete;
+};
+
+static_assert(std::output_iterator<cpp20_output_iterator<int*>, int>);
+
// Iterator adaptor that counts the number of times the iterator has had a successor/predecessor
// operation called. Has two recorders:
// * `stride_count`, which records the total number of calls to an op++, op--, op+=, or op-=.
Index: libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.output/output_iterator.compile.pass.cpp
===================================================================
--- libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.output/output_iterator.compile.pass.cpp
+++ libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.output/output_iterator.compile.pass.cpp
@@ -28,6 +28,15 @@
static_assert( std::output_iterator<cpp17_output_iterator<T*>, DerivedFromT>);
static_assert(!std::output_iterator<cpp17_output_iterator<DerivedFromT*>, T>);
+static_assert( std::output_iterator<cpp20_output_iterator<int*>, int>);
+static_assert( std::output_iterator<cpp20_output_iterator<int*>, short>);
+static_assert( std::output_iterator<cpp20_output_iterator<int*>, long>);
+static_assert( std::output_iterator<cpp20_output_iterator<T*>, T>);
+static_assert(!std::output_iterator<cpp20_output_iterator<T const*>, T>);
+static_assert( std::output_iterator<cpp20_output_iterator<T*>, T const>);
+static_assert( std::output_iterator<cpp20_output_iterator<T*>, DerivedFromT>);
+static_assert(!std::output_iterator<cpp20_output_iterator<DerivedFromT*>, T>);
+
// Not satisfied when the iterator is not an input_or_output_iterator
static_assert(!std::output_iterator<void, int>);
static_assert(!std::output_iterator<void (*)(), int>);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122072.420520.patch
Type: text/x-patch
Size: 2702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220405/18a7e52e/attachment.bin>
More information about the libcxx-commits
mailing list