
10 Jan
2012
10 Jan
'12
9:49 p.m.
On Tue, Jan 10, 2012 at 10:34 PM, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
2012/1/10 Vladimír Třebický <vladimir.trebicky@gmail.com>
boost::function<void(int)> f = boost::bind(boost::weak_fn(&Foo::bar, some_weak_ptr), _1); f(1);
It's it better to bind &Foo::bar directly?
boost::function<void(int)> f = boost::bind(&Foo::bar, some_weak_ptr, _1);
Much simpler in my opinion.
That cannot be done, boost::bind() indeed accepts references, pointers and shared_ptrs for member functions but doesn't accept weak pointers, because a weak pointer cannot be trivially converted to shared_ptr (or anything that leads to the corresponding class instance).
Roman Perepelitsa.
V.