7 May
2004
7 May
'04
1:55 a.m.
Steve Folly
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