
Dan Eloff <dan.eloff@gmail.com> writes:
For things like this the solution is usually to store the dereferenced value inside the iterator itself. You might look into using boost::optional for efficiency in this case.
If I store it in the iterator I get crashes because a reference is floating around to the long dead temporary iterator returned from post increment.
Dereference can return by value. That's normal for input iterators. But IIRC, the user of an input iterator isn't allowed to bind a reference to or take the address of the result of dereferencing anyway. So you might want to fix the code that does that.
I can store it in the parent (container) class of the iterator ( what I do now anyway ) but I need to store two values with post increment.
I'm not sure there _is_ a good reason. If you'd like to patch it to do it the other way, and if all of the Boost.Python regression tests still pass, I'll apply your patch.
If only so nobody else will have to go through what I just did today and yesterday I will make the patch. I'll post to the C++-sig when I've got it.
Please try to run the regression tests first! -- Dave Abrahams Boost Consulting http://www.boost-consulting.com