|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-28 09:17:00
From: "Richard Wolf" <richard_at_[hidden]>
> Hi
>
> I'm trying to use make_indirect_iterator on a container of shared_ptrs as
> follows:
>
[...]
> int main()
> {
> list<shared_ptr<A> > List2;
>
> // This doesn't work
> for_each(make_indirect_iterator(List2.begin()),
> make_indirect_iterator(List2.end()),
> mem_fun_ref(&A::f));
> }
The reason is that make_indirect_iterator tries to instantiate
std::iterator_traits< shared_ptr<A> >, and this fails, because shared_ptr<A>
is not an iterator.
You can make the for_each work by using
for_each(List2.begin(), List2.end(), boost::mem_fn(&A::f)); // in
<boost/mem_fn.hpp>
if that's what you want.
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