From 5f1db7627f6eea2050c3d71f17bca5ecf586a813 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 24 Sep 2021 13:23:34 +0100 Subject: [PATCH] libstdc++: Improve types used as iterators in testsuite Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * testsuite/25_algorithms/copy/34595.cc: Add missing operation for type used as an iterator. * testsuite/25_algorithms/unique_copy/check_type.cc: Likewise. --- libstdc++-v3/testsuite/25_algorithms/copy/34595.cc | 5 +++-- .../25_algorithms/unique_copy/check_type.cc | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc b/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc index c534eeb..513425a 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc @@ -27,11 +27,12 @@ class Counting_output_iterator public: Counting_output_iterator() : c(0) {} Counting_output_iterator& operator++() { return *this; } + Counting_output_iterator operator++(int) { return *this; } Counting_output_iterator& operator*() { return *this; } - + template void operator=(const T&) { ++c; } - + std::size_t current_counter() const { return c; } }; diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc index af86548..27b3579 100644 --- a/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc @@ -25,27 +25,35 @@ using __gnu_test::input_iterator_wrapper; using __gnu_test::output_iterator_wrapper; -struct S1 { }; +template +struct iter_facade +{ + T& operator++(); + T operator++(int); + T& operator*() const; +}; + +struct S1 : iter_facade { }; -struct S2 +struct S2 : iter_facade { S2(const S1&) {} }; -bool +bool operator==(const S1&, const S1&) {return true;} -struct X1 { }; +struct X1 : iter_facade { }; -struct X2 +struct X2 : iter_facade { X2(const X1&) {} }; -bool +bool predicate(const X1&, const X1&) {return true;} -output_iterator_wrapper +output_iterator_wrapper test1(input_iterator_wrapper& s1, output_iterator_wrapper& s2) { return std::unique_copy(s1, s1, s2); } -- 2.7.4