Alexander Borghgraef
Hi all,
I've been experimenting with indirect_iterator, which seems to be a very useful concept. However, I'm having some trouble getting it to work in the case where I want to fill a container with pointers to values, not just getting at the data. For example, this compiles but segfaults:
std::vector < int * > v( 10 ); std::fill( boost::make_indirect_iterator( v.begin() ), boost::make_indirect_iterator( v.end() ), 1.0 );
:) Yes, that's expected. When dereferenced, indirect_iterator gives you a reference onto an existing value.
Why isn't this working?
It wasn't designed to do that.
Also, some way to get it to work as a back_insert_iterator would be interesting, does this exist (aside from writing your own)?
Neither exists, but for either one, writing your own is possible using iterator_facade. The tutorial is at http://www.boost.org/libs/iterator/doc/iterator_facade.html#tutorial-example
If not, are there any plans to incorporate it in future versions?
There are no such plans. It would impose an overhead on other uses that people shouldn't have to pay. -- Dave Abrahams Boost Consulting www.boost-consulting.com