From: Jonathan Wakely Date: Fri, 25 Oct 2019 17:02:43 +0000 (+0100) Subject: Use implicitly-defined copy operations for test iterators X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a70fb8750ecb24f57066a9249acf7cf6bf6958d;p=gcc.git 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. From-SVN: r277459 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7997273a857..0e0a963bcbe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2019-10-25 Jonathan Wakely + * 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. + * include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc before making the std::allocator destructor constexpr. * testsuite/20_util/allocator/requirements/constexpr.cc: New test. 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 operator*() const @@ -144,14 +149,6 @@ namespace __gnu_test return WritableObject(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 ContainerType; typedef std::forward_iterator_tag iterator_category; + forward_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) : input_iterator_wrapper(_ptr, SharedInfo_in) { } - forward_iterator_wrapper(const forward_iterator_wrapper& in) - : input_iterator_wrapper(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 ContainerType; typedef std::bidirectional_iterator_tag iterator_category; + bidirectional_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) : forward_iterator_wrapper(_ptr, SharedInfo_in) { } - bidirectional_iterator_wrapper(const bidirectional_iterator_wrapper& in) - : forward_iterator_wrapper(in) + bidirectional_iterator_wrapper() + : forward_iterator_wrapper() { } - bidirectional_iterator_wrapper(): forward_iterator_wrapper() - { } +#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 ContainerType; typedef std::random_access_iterator_tag iterator_category; + random_access_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) : bidirectional_iterator_wrapper(_ptr, SharedInfo_in) { } - random_access_iterator_wrapper(const random_access_iterator_wrapper& in) - : bidirectional_iterator_wrapper(in) + random_access_iterator_wrapper() + : bidirectional_iterator_wrapper() { } - random_access_iterator_wrapper():bidirectional_iterator_wrapper() - { } +#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++()