Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-13 07:59:23


Interesting. That seems to work for me, too. Still, shouldn't the other one
work as well?

Here's another quirk:

------

#include <boost/bind.hpp>
#include <boost/utility.hpp>
struct Y : boost::noncopyable // prevents slicing
{
    virtual int f(const char*) = 0;
};

struct X : Y
{
    int f(const char*);
};

X x;

int y = boost::bind(&Y::f, &x, _1)("hello"); // OK
int z = boost::bind(&Y::f, _1, "hello")(*static_cast<Y*>(&x)); // OK

int z2 = boost::bind(&Y::f, _1, "hello")(
            boost::ref(*static_cast<Y*>(&x))); // not OK

int z3 = boost::bind(
            boost::bind(&Y::f, _1, "hello"), ref(*static_cast<Y*>(&x))
         )(); // OK

----- Original Message -----
From: "Vladimir Voinkov" <voinkovv_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, November 13, 2001 5:19 AM
Subject: RE: [boost] bind/mem_fn problem

> I've compiled:
>
> int z = boost::bind(&X::f, _1, "hello")(x);
>
> Vladimir
>
> -----Original Message-----
> From: David Abrahams [mailto:david.abrahams_at_[hidden]]
> Sent: Tuesday, November 13, 2001 11:27 AM
> To: boost
> Cc: Peter Dimov
> Subject: [boost] bind/mem_fn problem
>
>
> 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?
>
> ===================================================
> David Abrahams, C++ library designer for hire
> resume: http://users.rcn.com/abrahams/resume.html
>
> C++ Booster (http://www.boost.org)
> email: david.abrahams_at_[hidden]
> ===================================================
>
>
>
> Info: http://www.boost.org Unsubscribe:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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