Alexander Borghgraef
But it is possible to do input with an indirect_iterator no? I mean, there's the example from the documentation (somewhat summarized):
Try compiling and running the example, then try compiling and running your "somewhat summarized" version. Notice anything? When your version crashes, it will reveal to you the important things you left out: our example initializes all those pointers to refer to valid locations first.
char* pointers_to_chars[N]; char* pointers_to_mutable_chars[N];
boost::indirect_iterator
mutable_indirect_first(pointers_to_mutable_chars), mutable_indirect_last(pointers_to_mutable_chars + N); boost::indirect_iterator const_indirect_first(pointers_to_chars), const_indirect_last(pointers_to_chars + N); std::transform(const_indirect_first, const_indirect_last, mutable_indirect_first, std::bind1st(std::plus<char>(), 1));
And this is the error message:
/usr/include/boost/shared_ptr.hpp:247: typename boost::detail::shared_ptr_traits<T>::reference boost::shared_ptr<T>::operator*() const [with T = double]: Assertion `px != 0' failed.
Right; that's not a crash. It's an assertion.
I must say it's all a bit beyond me right now. Could you explain why things go wrong here?
indirect_iterator doesn't automagically create the things the pointers are supposed to be referring to, and dereferencing a NULL pointer is illegal. HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com