[committed] libstdc++: Support N3644 "Null Forward Iterators" for testsuite iterators
Jonathan Wakely
jwakely@redhat.com
Thu Feb 27 13:03:00 GMT 2020
Comparing value-initialized forward_iterator_wrapper<T> objects fails an
assertion, but should be valid in C++14 and later.
* testsuite/util/testsuite_iterators.h (forward_iterator_wrapper): Add
equality comparisons that support value-initialized iterators.
Tested powerpc64le-linux, committed to master.
-------------- next part --------------
commit e94f2542305ccb5c4a3c4e5e8212713747623417
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Feb 27 13:01:14 2020 +0000
libstdc++: Support N3644 "Null Forward Iterators" for testsuite iterators
Comparing value-initialized forward_iterator_wrapper<T> objects fails an
assertion, but should be valid in C++14 and later.
* testsuite/util/testsuite_iterators.h (forward_iterator_wrapper): Add
equality comparisons that support value-initialized iterators.
diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h
index 7b7093919b7..417dff23c50 100644
--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -337,6 +337,26 @@ namespace __gnu_test
++*this;
return tmp;
}
+
+#if __cplusplus >= 201402L
+ bool
+ operator==(const forward_iterator_wrapper& it) const noexcept
+ {
+ // Since C++14 value-initialized forward iterators are comparable.
+ if (this->SharedInfo == nullptr || it.SharedInfo == nullptr)
+ return this->SharedInfo == it.SharedInfo && this->ptr == it.ptr;
+
+ const input_iterator_wrapper<T>& base_this = *this;
+ const input_iterator_wrapper<T>& base_that = it;
+ return base_this == base_that;
+ }
+
+ bool
+ operator!=(const forward_iterator_wrapper& it) const noexcept
+ {
+ return !(*this == it);
+ }
+#endif
};
/**
More information about the Libstdc++
mailing list