Boost logo

Boost Users :

From: Alexander Borghgraef (alexander.borghgraef.rma_at_[hidden])
Date: 2005-09-28 04:08:09


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
);

Another case:

std::vector< boost::shared_ptr<double> > v(10);
std::vector< boost::shared_ptr<double> > w(10);
// v gets filled somehow
std::copy( boost::make_indirect_iterator( v.begin() ),
boost::make_indirect_iterator( v.end() ),
boost::make_indirect_iterator( w.begin() )
);

Why isn't this working? Also, some way to get it to work as a
back_insert_iterator would be interesting,
does this exist (aside from writing your own)? If not, are there any plans
to incorporate it in future versions?

--
Alex Borghgraef
--
Alex Borghgraef


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net