[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos)] Conditionally disable copyability of the test_range::iterator wrapper
Patrick Palka
ppalka@gcc.gnu.org
Wed Jan 22 18:45:00 GMT 2020
https://gcc.gnu.org/g:05e7e7eec2f44a0bff12ded0c30bebdcc2d7f4ae
commit 05e7e7eec2f44a0bff12ded0c30bebdcc2d7f4ae
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Jan 22 13:39:24 2020 -0500
Conditionally disable copyability of the test_range::iterator wrapper
As of P1207, input_iterators and output_iterators are no longer required to be
copyable, but forward_iterators are. Reflect these assumptions in the
test_range::iterator wrapper by conditionally disabling its copyability.
Diff:
---
libstdc++-v3/testsuite/util/testsuite_iterators.h | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h
index 6667a3a..22fa3fd 100644
--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -654,12 +654,33 @@ namespace __gnu_test
{ return iter -= n; }
};
+ template<bool active>
+ struct disable_copy { };
+
+ template<>
+ struct disable_copy<true>
+ {
+ disable_copy() noexcept = default;
+
+ disable_copy(disable_copy&&) noexcept = default;
+ disable_copy&
+ operator=(disable_copy&&) noexcept = default;
+
+ disable_copy(const disable_copy&) noexcept = delete;
+ disable_copy&
+ operator=(const disable_copy&) noexcept = delete;
+ };
+
+ template<>
+ struct disable_copy<false> { };
+
// A type meeting the minimum std::range requirements
template<typename T, template<typename> class Iter>
class test_range
{
// Adds default constructor to Iter<T> if needed
- struct iterator : Iter<T>
+ // and removes copyability if the iterator is not a forward iterator
+ struct iterator : Iter<T>, disable_copy<!std::forward_iterator<Iter<T>>>
{
using Iter<T>::Iter;
More information about the Libstdc++-cvs
mailing list