Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-13 08:21:35


From: "David Abrahams" <david.abrahams_at_[hidden]>
> The following short program doesn't compile:
>
> #include <boost/bind.hpp>
> struct X
> {
> int f(const char*);
> };
> X x;
> int y = boost::bind(&X::f, &x, _1)("hello"); // OK
> int z = boost::bind(&X::f, _1, "hello")(&x); // not OK
>
> Shouldn't it work?

Yes it should. Unfortunately &x is a temporary, and the bound function
doesn't accept temporaries (the argument forwarding problem.)

Plain x and ref(x) will work. So will declaring a named temporary X * px =
&x.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk