reference type of output_iterator_wrapper
Doug Gregor
dgregor@cs.indiana.edu
Mon Apr 17 13:55:00 GMT 2006
The testsuite_iterators.h header, part of the libstdc++-v3 testsuite,
contains the struct template output_iterator wrapper. In the
definition of this wrapper, the nested "reference" type (defined
through std::iterator) conflicts with the type returned from operator*:
template<class T>
struct output_iterator_wrapper: public std::iterator
<std::output_iterator_tag, T, ptrdiff_t, T*, T&>
{
// ...
WritableObject<T>
operator*() const
{
ITERATOR_VERIFY(ptr < SharedInfo->last);
ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first]
== false);
return WritableObject<T>(ptr, SharedInfo);
}
// ...
};
output_iterator_wrapper<T>::reference is defined to be T&, whereas
operator* returns WritableObject<T>. Sure, you won't find anywhere in
the standard that explicitly says that the "reference" type needs to
be the same as the return type of operator*, but it's implied by the
uses of "reference" (e.g., in reverse_iterator). Anyway, I doubt the
current output_iterator_wrapper would pass a concept checker, and it
fails in ConceptGCC.
I suggest changing the last argument of the std::iterator base to
WritableObject<T>. Patch attached.
Doug
--- testsuite_iterators.h.old 2006-04-17 09:50:07.000000000 -0400
+++ testsuite_iterators.h 2006-04-17 09:50:37.000000000 -0400
@@ -115,7 +115,7 @@
*/
template<class T>
struct output_iterator_wrapper: public std::iterator
- <std::output_iterator_tag, T, ptrdiff_t, T*, T&>
+ <std::output_iterator_tag, T, ptrdiff_t, T*, WritableObject<T> >
{
typedef OutputContainer<T> ContainerType;
T* ptr;
2006-04-17 Douglas Gregor <dgregor@cs.indiana.edu>
* testsuite/testsuite_iterators.h (output_iterator_wrapper):
WritableObject<T> is the reference type.
More information about the Libstdc++
mailing list