Boost logo

Boost Users :

From: Johannes Brunen (jbrunen_at_[hidden])
Date: 2006-12-01 07:10:22


Hi,
I have the following problem and don't know how to design it with the
boost tools at hand:

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(???);
};

Now, f1 and f2 should call F, but f1 should determine that F calls X::f
polymorphically and f2 should determine that F calls X::g
polymorphically.

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

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);
}

Y::F(???) {
    smart_ptr<Y> sp1(new Y);
    smart_ptr<Y> sp2(new Y);

    // Either call Y::f on sp1 and sp2, or call Y::g(5) on sp1 and sp2
}

Is this possible? I have looked into the documentation of boost::bind,
boost::mem_fn and boost::function but didn't find a way to do that.
Could someone give me some hint?

With best regards

Johannes Brunen


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