Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-12-01 13:13:27


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Johannes Brunen
> Sent: Friday, December 01, 2006 7:10 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] [bind,function,mem_fn] Connection to a base
class

[Nat] This is top-of-the-head, no tests.
 
> I have a base class X with two functions f and g
>
> class X {
> virtual bool f() const;
> virtual bool g(int) const;
> };
>
> and another class Y with functions f1, f2 and F
>
> class Y {
> void f1();
> void f2();
> void F(???);

[Nat] Seems like you'd want to make F accept boost::function<bool()>,
and call it without arguments.

> };
>
> Y::f1() {
> // call F so that F works on X::f
> F(??? X::f);

[Nat] F(boost::bind(&X::f, this))

> }
>
> Y::f2() {
> // call F so that F works on Y::g but with g's int parameter known
> and determined in Y::f2
> int v = 5;
> F(??? X::g, v);

[Nat] F(boost::bind(&X::g, this, v))

> }


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