|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-05-06 20:55:27
Steve Folly <boost_at_[hidden]> writes:
> Hi,
>
> I've converted a container to use shared_ptrs instead of regular pointers,
> now my for_each algorithm doesn't work:
>
> Before:
>
> class Attr;
>
> std::vector< Attr* > mAttributes;
> .
> .
> .
> std::for_each( mAttributes.begin(), mAttributes.end(),
> std::bind2nd( std::mem_fn( &Attr::Write ), output ) );
>
> After:
>
> std::vector< shared_ptr<Attr> > mAttributes;
>
>
> Now it doesn't compile because (of course) Attr::Write is not a method of
> shared_ptr<Attr>.
>
> Do I have to use boost's bind and mem_fn objects instead of std?
Yes; bind and mem_fn handle this problem (and quite a few others) automatically.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
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