Commit 0a70fb87 by Jonathan Wakely Committed by Jonathan Wakely

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
parent eadcde8e
2019-10-25 Jonathan Wakely <jwakely@redhat.com> 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 * include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc
before making the std::allocator destructor constexpr. before making the std::allocator destructor constexpr.
* testsuite/20_util/allocator/requirements/constexpr.cc: New test. * testsuite/20_util/allocator/requirements/constexpr.cc: New test.
......
...@@ -132,9 +132,14 @@ namespace __gnu_test ...@@ -132,9 +132,14 @@ namespace __gnu_test
ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last); ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last);
} }
output_iterator_wrapper(const output_iterator_wrapper& in) #if __cplusplus >= 201103L
: ptr(in.ptr), SharedInfo(in.SharedInfo) output_iterator_wrapper() = delete;
{ }
output_iterator_wrapper(const output_iterator_wrapper&) = default;
output_iterator_wrapper&
operator=(const output_iterator_wrapper&) = default;
#endif
WritableObject<T> WritableObject<T>
operator*() const operator*() const
...@@ -145,14 +150,6 @@ namespace __gnu_test ...@@ -145,14 +150,6 @@ namespace __gnu_test
} }
output_iterator_wrapper& output_iterator_wrapper&
operator=(const output_iterator_wrapper& in)
{
ptr = in.ptr;
SharedInfo = in.SharedInfo;
return *this;
}
output_iterator_wrapper&
operator++() operator++()
{ {
ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
...@@ -203,7 +200,7 @@ namespace __gnu_test ...@@ -203,7 +200,7 @@ namespace __gnu_test
std::ptrdiff_t, T*, T&> std::ptrdiff_t, T*, T&>
{ {
protected: protected:
input_iterator_wrapper() input_iterator_wrapper() : ptr(0), SharedInfo(0)
{ } { }
public: public:
...@@ -215,9 +212,12 @@ namespace __gnu_test ...@@ -215,9 +212,12 @@ namespace __gnu_test
: ptr(_ptr), SharedInfo(SharedInfo_in) : ptr(_ptr), SharedInfo(SharedInfo_in)
{ ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last); } { ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last); }
input_iterator_wrapper(const input_iterator_wrapper& in) #if __cplusplus >= 201103L
: ptr(in.ptr), SharedInfo(in.SharedInfo) input_iterator_wrapper(const input_iterator_wrapper&) = default;
{ }
input_iterator_wrapper&
operator=(const input_iterator_wrapper&) = default;
#endif
bool bool
operator==(const input_iterator_wrapper& in) const operator==(const input_iterator_wrapper& in) const
...@@ -248,14 +248,6 @@ namespace __gnu_test ...@@ -248,14 +248,6 @@ namespace __gnu_test
} }
input_iterator_wrapper& input_iterator_wrapper&
operator=(const input_iterator_wrapper& in)
{
ptr = in.ptr;
SharedInfo = in.SharedInfo;
return *this;
}
input_iterator_wrapper&
operator++() operator++()
{ {
ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
...@@ -298,19 +290,20 @@ namespace __gnu_test ...@@ -298,19 +290,20 @@ namespace __gnu_test
{ {
typedef BoundsContainer<T> ContainerType; typedef BoundsContainer<T> ContainerType;
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
forward_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) forward_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
: input_iterator_wrapper<T>(_ptr, SharedInfo_in) : input_iterator_wrapper<T>(_ptr, SharedInfo_in)
{ } { }
forward_iterator_wrapper(const forward_iterator_wrapper& in) forward_iterator_wrapper()
: input_iterator_wrapper<T>(in)
{ } { }
forward_iterator_wrapper() #if __cplusplus >= 201103L
{ forward_iterator_wrapper(const forward_iterator_wrapper&) = default;
this->ptr = 0;
this->SharedInfo = 0; forward_iterator_wrapper&
} operator=(const forward_iterator_wrapper&) = default;
#endif
T& T&
operator*() const operator*() const
...@@ -352,24 +345,22 @@ namespace __gnu_test ...@@ -352,24 +345,22 @@ namespace __gnu_test
{ {
typedef BoundsContainer<T> ContainerType; typedef BoundsContainer<T> ContainerType;
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
bidirectional_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) bidirectional_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
: forward_iterator_wrapper<T>(_ptr, SharedInfo_in) : forward_iterator_wrapper<T>(_ptr, SharedInfo_in)
{ } { }
bidirectional_iterator_wrapper(const bidirectional_iterator_wrapper& in) bidirectional_iterator_wrapper()
: forward_iterator_wrapper<T>(in) : 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& bidirectional_iterator_wrapper&
operator=(const bidirectional_iterator_wrapper& in) operator=(const bidirectional_iterator_wrapper&) = default;
{ #endif
this->ptr = in.ptr;
this->SharedInfo = in.SharedInfo;
return *this;
}
bidirectional_iterator_wrapper& bidirectional_iterator_wrapper&
operator++() operator++()
...@@ -417,24 +408,22 @@ namespace __gnu_test ...@@ -417,24 +408,22 @@ namespace __gnu_test
{ {
typedef BoundsContainer<T> ContainerType; typedef BoundsContainer<T> ContainerType;
typedef std::random_access_iterator_tag iterator_category; typedef std::random_access_iterator_tag iterator_category;
random_access_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in) random_access_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
: bidirectional_iterator_wrapper<T>(_ptr, SharedInfo_in) : bidirectional_iterator_wrapper<T>(_ptr, SharedInfo_in)
{ } { }
random_access_iterator_wrapper(const random_access_iterator_wrapper<T>& in) random_access_iterator_wrapper()
: bidirectional_iterator_wrapper<T>(in) : 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& random_access_iterator_wrapper&
operator=(const random_access_iterator_wrapper& in) operator=(const random_access_iterator_wrapper&) = default;
{ #endif
this->ptr = in.ptr;
this->SharedInfo = in.SharedInfo;
return *this;
}
random_access_iterator_wrapper& random_access_iterator_wrapper&
operator++() operator++()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment