|
Boost Users : |
Subject: Re: [Boost-users] Why doesn't boost::function use get_pointer() ?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-09-14 17:47:41
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<void(X*,int)> 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<void(const shared_ptr<X>&, int)> foo;
In Christ,
Steven Watanabe
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