boost::zip_iterator does not work with std::istreambuf_iterator

1. boost::zip_iterator requires a readable iterator.
2. std::istreambuf_iterator is a readable iterator.
3. boost::zip_iterator cannot dereference std::istream_iterator because
std::istreambuf_iterator returns by value while boost::zip_iterator returns
by reference; the exact error message is
invalid initialization of non-const reference of type ‘char&’ from an
rvalue of type ‘std::istreambuf_iterator ::char_type’ Contradiction? Am I missing anything?
Chris

on Sat Sep 03 2011, Krzysztof Żelechowski
1. boost::zip_iterator requires a readable iterator. 2. std::istreambuf_iterator is a readable iterator. 3. boost::zip_iterator cannot dereference std::istream_iterator because std::istreambuf_iterator returns by value while boost::zip_iterator returns by reference; the exact error message is invalid initialization of non-const reference of type ‘char&’ from an rvalue of type ‘std::istreambuf_iterator
::char_type’
Contradiction? Am I missing anything?
You're probably not missing anything. I think the docs are wrong. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote:
on Sat Sep 03 2011, Krzysztof Żelechowski
wrote: 1. boost::zip_iterator requires a readable iterator. 2. std::istreambuf_iterator is a readable iterator. 3. boost::zip_iterator cannot dereference std::istream_iterator because std::istreambuf_iterator returns by value while boost::zip_iterator returns by reference; the exact error message is invalid initialization of non-const reference of type ‘char&’ from an rvalue of type ‘std::istreambuf_iterator
::char_type’
Contradiction? Am I missing anything?
You're probably not missing anything. I think the docs are wrong.
I would rather prefer if you declared that the implementation is wrong... I have written an alternative implementation named iterator_pair that does not have this limitation (although it is probably not as cool as zip_iterator).
participants (2)
-
Dave Abrahams
-
Krzysztof Żelechowski