|
Boost Users : |
From: Kevin Heifner (heifner_k_at_[hidden])
Date: 2007-03-05 16:05:25
Steven S. Klug wrote:
> Is there any way using BLL's bind to bind to shared_ptrs in a container?
>
> e.g.:
>
> class MyClass
> {
> public:
> std::string MyFunc()
> {
> return str;
> }
>
> private:
> string str;
> };
>
> vector<shared_ptr<MyClass> > v;
>
> find_if( v.begin(), v.end(), boost::lambda::bind( &MyClass::MyFunc, _1 ) ==
> string( "steve" ) );
boost::lambda::bind does not support shared_ptrs directly as does
boost::bind, however you can easily get the same behavior by
using the boost::lambda::_1 deference capability:
find_if( v.begin(), v.end(), boost::lambda::bind(
&MyClass::MyFunc, *_1 ) == string( "steve" ) );
KevinH
-- Kevin Heifner heifner @ ociweb.com http://heifner.blogspot.com Object Computing, Inc. (OCI) www.ociweb.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