Topic: output_iterator::value_type void?


Author: rob@muon.robnet.com
Date: Tue, 8 May 2001 16:09:48 GMT
Raw View
I see that 24.3.1p1 requires that for an output iterator
iterator_traits<I>::value_type must be void.  Why is that?  I can see
that it would usually not be needed, but what's the harm in requiring
it?  It would seem that a template (member) function might need a
temporary value while preparing data to stuff into the output
iterator.  What am I missing?

Here's the hypothetical situation (meaning something I tried at work)
that made me to wonder:


class some_data_source
{
public:
        // _O is output iterator, probably std::back_inserter...
        template <class _O>
        void getCollection(_O o)
        {
                std::iterator_traits<_O>::value_type tmp;
                ostream_something >> tmp;
                *o++ = tmp;
        }
};


Thanks for any and all comments.

Later,
Rob

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]