
14 Sep
2010
14 Sep
'10
9:47 p.m.
AMDG Peter Soetens wrote:
When using boost::bind, I can write this:
struct X { void foo(int) {} };
shared_ptr<X> x( new X ); // bind takes shared_ptr: bind(&X::foo, x, 3)();
But I can't write this:
function
foo = &X::foo; // function refuses shared_ptr: foo(x,1); Why doesn't boost::function have the same get_pointer() trick ?
Overload resolution for calling a boost::function is exactly the same as for calling a function with that signature. shared_ptr<X> is not convertible to X*, so the call fails.
Or how can I rewrite the function signature such that it does work with shared pointers ?
function