Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost function with virtual methods
From: Igor R (boost.lists_at_[hidden])
Date: 2011-07-02 13:21:13

> typedef boost::function<void (RegressionTestScenario*, const std::string &)> actionFuntion;
> typedef boost::shared_ptr<actionFuntion> actionFuntionPtr;
> class CurveGenRegressionTestScenario : public RegressionTestScenario
> {
> public:
>         void changeBaseDate(const std::string &argument);
> and I am trying to use the following:
> actionFuntion funPtr;
> funPtr = &CurveGenRegressionTestScenario::changeBaseDate;
> but it fails. I have no idea why. Could someone give me a hint?

boost::function<void (RegressionTestScenario*, const std::string &)>
-- is a callable with 2 arguments.
&CurveGenRegressionTestScenario::changeBaseDate -- is a ptr to a
member function.
These 2 types are incompatible.
You probably should look at Boost.Bind to accomplish your task:

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at