Suggestion for iterator_facade documentation
It is not immediately obvious how to correctly specify the template
arguments for boost::iterator_facade<> with an output iterator. This
particular case is not mentioned in the tutorial and the first
impression is that using such category as std::output_iterator_tag
should be all that's required. This is not the case; in order for the
postincrement temporary NOT to create a copy of a [fake] pointed-to
value OR a copy of the proxy, the user has to be very careful about
Value and Reference arguments. Took me 3 tries and a thorough look into
the sources to get it right: Value=
on Wed Jul 11 2007, Max Motovilov
It is not immediately obvious how to correctly specify the template arguments for boost::iterator_facade<> with an output iterator. This particular case is not mentioned in the tutorial and the first impression is that using such category as std::output_iterator_tag should be all that's required. This is not the case; in order for the postincrement temporary NOT to create a copy of a [fake] pointed-to value OR a copy of the proxy, the user has to be very careful about Value and Reference arguments. Took me 3 tries and a thorough look into the sources to get it right: Value=
and Reference=Proxy&. Would be nice to add this use case to the tutorial since it is definitely tricky and error-prone as it is.
It sounds like you're the perfect candidate to write those docs. Patches gratefully accepted. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
David Abrahams wrote:
It sounds like you're the perfect candidate to write those docs.
Ok, I'll see if I can figure out how to get to the doc source. Nothing is quite like practical experience :-D ...Max... PS. I'm curious -- WAS there any intention to support output iterators as a specific case in iterator_facade, or the check for convertibility between reference type and value type was there for different reasons and just happened to cover this particular situation? In my case, I don't really have a natural value type -- or rather the same proxy may support multiple unrelated types -- that's why I did not attach any importance to initial selection of the template parameter...
on Wed Jul 11 2007, Max Motovilov
David Abrahams wrote:
It sounds like you're the perfect candidate to write those docs.
Ok, I'll see if I can figure out how to get to the doc source. Nothing is quite like practical experience :-D
...Max...
PS. I'm curious -- WAS there any intention to support output iterators as a specific case in iterator_facade,
I honestly don't remember, sorry. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
participants (2)
-
David Abrahams
-
Max Motovilov