RE: [Boost-users] Re: shared_ptrs with std::mem_fn
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.
Why is this a problem? I thought std::mem_fn called the function through the -> operator, which 'should' work (but obviously doesn't). I would think this would only crop up through mem_fun_ref, but then you wouldn't have a container of shared_ptr<Attr>, but Attr. --Baffled --Mark Storer Senior Software Engineer Verity, Inc.
"Mark Storer"
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.
Why is this a problem? I thought std::mem_fn called the function through the -> operator, which 'should' work (but obviously doesn't). I would think this would only crop up through mem_fun_ref, but then you wouldn't have a container of shared_ptr<Attr>, but Attr.
boost::mem_fn erases the need for a separate mem_fn_ref. If http://www.boost.org/libs/bind/mem_fn.html fails to explain it to you, please ask more specific questions. HTH, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Mark Storer