diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-10-25 18:02:43 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-10-25 18:02:43 +0100 |
commit | 0a70fb8750ecb24f57066a9249acf7cf6bf6958d (patch) | |
tree | e14ad0de3925717e4b25fa61cbd1ce56271d6c54 | |
parent | eadcde8e8f53c950fc17b52fd33adda40d28f7af (diff) | |
download | gcc-0a70fb8750ecb24f57066a9249acf7cf6bf6958d.zip gcc-0a70fb8750ecb24f57066a9249acf7cf6bf6958d.tar.gz gcc-0a70fb8750ecb24f57066a9249acf7cf6bf6958d.tar.bz2 |
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/testsuite_iterators.h | 89 |
2 files changed, 47 insertions, 50 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7997273..0e0a963 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2019-10-25 Jonathan Wakely <jwakely@redhat.com> + * 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 42e4274..d9a3562 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 @@ -145,14 +150,6 @@ namespace __gnu_test } output_iterator_wrapper& - operator=(const output_iterator_wrapper& in) - { - ptr = in.ptr; - SharedInfo = in.SharedInfo; - return *this; - } - - output_iterator_wrapper& operator++() { ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); @@ -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 @@ -248,14 +248,6 @@ namespace __gnu_test } input_iterator_wrapper& - operator=(const input_iterator_wrapper& in) - { - ptr = in.ptr; - SharedInfo = in.SharedInfo; - return *this; - } - - input_iterator_wrapper& operator++() { ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); @@ -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++() |