All of these special member functions do exactly what the compiler would
do anyway. By defining them as defaulted for C++11 and later we prevent
move constructors and move assignment operators being defined (which is
consistent with the previous semantics).

Also move default init of the input_iterator_wrapper members from the
derived constructor to the protected base constructor.

        * testsuite/util/testsuite_iterators.h (output_iterator_wrapper)
        (input_iterator_wrapper, forward_iterator_wrapper)
        bidirectional_iterator_wrapper, random_access_iterator_wrapper): Remove
        user-provided copy constructors and copy assignment operators so they
        are defined implicitly.
        (input_iterator_wrapper): Initialize members in default constructor.
        (forward_iterator_wrapper): Remove assignments to members of base.

Tested powerpc64le-linux, committed to trunk.

commit b44b241cab8af8af5d5ff6299c0409f4be2e7bbc
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Thu Oct 24 22:00:27 2019 +0100

    Use implicitly-defined copy operations for test iterators
    
    All of these special member functions do exactly what the compiler would
    do anyway. By defining them as defaulted for C++11 and later we prevent
    move constructors and move assignment operators being defined (which is
    consistent with the previous semantics).
    
    Also move default init of the input_iterator_wrapper members from the
    derived constructor to the protected base constructor.
    
            * testsuite/util/testsuite_iterators.h (output_iterator_wrapper)
            (input_iterator_wrapper, forward_iterator_wrapper)
            bidirectional_iterator_wrapper, random_access_iterator_wrapper): 
Remove
            user-provided copy constructors and copy assignment operators so 
they
            are defined implicitly.
            (input_iterator_wrapper): Initialize members in default constructor.
            (forward_iterator_wrapper): Remove assignments to members of base.

diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h 
b/libstdc++-v3/testsuite/util/testsuite_iterators.h
index 42e42740df9..d9a35622fb7 100644
--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -132,9 +132,14 @@ namespace __gnu_test
       ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last);
     }
 
-    output_iterator_wrapper(const output_iterator_wrapper& in)
-    : ptr(in.ptr), SharedInfo(in.SharedInfo)
-    { }
+#if __cplusplus >= 201103L
+    output_iterator_wrapper() = delete;
+
+    output_iterator_wrapper(const output_iterator_wrapper&) = default;
+
+    output_iterator_wrapper&
+    operator=(const output_iterator_wrapper&) = default;
+#endif
 
     WritableObject<T>
     operator*() const
@@ -144,14 +149,6 @@ namespace __gnu_test
       return WritableObject<T>(ptr, SharedInfo);
     }
 
-    output_iterator_wrapper&
-    operator=(const output_iterator_wrapper& in)
-    {
-      ptr = in.ptr;
-      SharedInfo = in.SharedInfo;
-      return *this;
-    }
-
     output_iterator_wrapper&
     operator++()
     {
@@ -203,7 +200,7 @@ namespace __gnu_test
                         std::ptrdiff_t, T*, T&>
   {
   protected:
-    input_iterator_wrapper()
+    input_iterator_wrapper() : ptr(0), SharedInfo(0)
     { }
 
   public:
@@ -215,9 +212,12 @@ namespace __gnu_test
     : ptr(_ptr), SharedInfo(SharedInfo_in)
     { ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last); }
 
-    input_iterator_wrapper(const input_iterator_wrapper& in)
-    : ptr(in.ptr), SharedInfo(in.SharedInfo)
-    { }
+#if __cplusplus >= 201103L
+    input_iterator_wrapper(const input_iterator_wrapper&) = default;
+
+    input_iterator_wrapper&
+    operator=(const input_iterator_wrapper&) = default;
+#endif
 
     bool
     operator==(const input_iterator_wrapper& in) const
@@ -247,14 +247,6 @@ namespace __gnu_test
       return &**this;
     }
 
-    input_iterator_wrapper&
-    operator=(const input_iterator_wrapper& in)
-    {
-      ptr = in.ptr;
-      SharedInfo = in.SharedInfo;
-      return *this;
-    }
-
     input_iterator_wrapper&
     operator++()
     {
@@ -298,19 +290,20 @@ namespace __gnu_test
   {
     typedef BoundsContainer<T> ContainerType;
     typedef std::forward_iterator_tag iterator_category;
+
     forward_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
     : input_iterator_wrapper<T>(_ptr, SharedInfo_in)
     { }
 
-    forward_iterator_wrapper(const forward_iterator_wrapper& in)
-    : input_iterator_wrapper<T>(in)
+    forward_iterator_wrapper()
     { }
 
-    forward_iterator_wrapper()
-    {
-      this->ptr = 0;
-      this->SharedInfo = 0;
-    }
+#if __cplusplus >= 201103L
+    forward_iterator_wrapper(const forward_iterator_wrapper&) = default;
+
+    forward_iterator_wrapper&
+    operator=(const forward_iterator_wrapper&) = default;
+#endif
 
     T&
     operator*() const
@@ -352,24 +345,22 @@ namespace __gnu_test
   {
     typedef BoundsContainer<T> ContainerType;
     typedef std::bidirectional_iterator_tag iterator_category;
+
     bidirectional_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
     : forward_iterator_wrapper<T>(_ptr, SharedInfo_in)
     { }
 
-    bidirectional_iterator_wrapper(const bidirectional_iterator_wrapper& in)
-    : forward_iterator_wrapper<T>(in)
+    bidirectional_iterator_wrapper()
+    : forward_iterator_wrapper<T>()
     { }
 
-    bidirectional_iterator_wrapper(): forward_iterator_wrapper<T>()
-    { }
+#if __cplusplus >= 201103L
+    bidirectional_iterator_wrapper(
+       const bidirectional_iterator_wrapper&) = default;
 
     bidirectional_iterator_wrapper&
-    operator=(const bidirectional_iterator_wrapper& in)
-    {
-      this->ptr = in.ptr;
-      this->SharedInfo = in.SharedInfo;
-      return *this;
-    }
+    operator=(const bidirectional_iterator_wrapper&) = default;
+#endif
 
     bidirectional_iterator_wrapper&
     operator++()
@@ -417,24 +408,22 @@ namespace __gnu_test
   {
     typedef BoundsContainer<T> ContainerType;
     typedef std::random_access_iterator_tag iterator_category;
+
     random_access_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
     : bidirectional_iterator_wrapper<T>(_ptr, SharedInfo_in)
     { }
 
-    random_access_iterator_wrapper(const random_access_iterator_wrapper<T>& in)
-    : bidirectional_iterator_wrapper<T>(in)
+    random_access_iterator_wrapper()
+    : bidirectional_iterator_wrapper<T>()
     { }
 
-    random_access_iterator_wrapper():bidirectional_iterator_wrapper<T>()
-    { }
+#if __cplusplus >= 201103L
+    random_access_iterator_wrapper(
+       const random_access_iterator_wrapper&) = default;
 
     random_access_iterator_wrapper&
-    operator=(const random_access_iterator_wrapper& in)
-    {
-      this->ptr = in.ptr;
-      this->SharedInfo = in.SharedInfo;
-      return *this;
-    }
+    operator=(const random_access_iterator_wrapper&) = default;
+#endif
 
     random_access_iterator_wrapper&
     operator++()

Reply via email to