G
Gert Van den Eynde
Hi all,
I'm struggling a bit with Functors generated for an ABC.
This is the functor code:
class Functor{
public:
virtual double operator(double x)=0
}
template <class T> class SpecFunctor: public Functor
{
private:
double (T::*fpt)(double x);
T* obj;
}
public:
SpecFunctor(T* _obj, double(T::*_fpt)(double x))
{
obj = _obj; fpt = _fpt;
}
virtual operator()(double x)
{
(*obj.*fpt)(x);
}
Now, this works fine for 'ordinary' classes T. However, I would like to have
it working for an ABC. When I use an ABC for T, I get warnings from g++
that obj_ will get initialzed after... I more or less understand why the
warnings appear (you cannot create an object for an ABC).
It's merely warnings, but I would like to clean it up. Is there a way to do
this without giving up the Functor or ABC?
Thanks for any tips,
gert
I'm struggling a bit with Functors generated for an ABC.
This is the functor code:
class Functor{
public:
virtual double operator(double x)=0
}
template <class T> class SpecFunctor: public Functor
{
private:
double (T::*fpt)(double x);
T* obj;
}
public:
SpecFunctor(T* _obj, double(T::*_fpt)(double x))
{
obj = _obj; fpt = _fpt;
}
virtual operator()(double x)
{
(*obj.*fpt)(x);
}
Now, this works fine for 'ordinary' classes T. However, I would like to have
it working for an ABC. When I use an ABC for T, I get warnings from g++
that obj_ will get initialzed after... I more or less understand why the
warnings appear (you cannot create an object for an ABC).
It's merely warnings, but I would like to clean it up. Is there a way to do
this without giving up the Functor or ABC?
Thanks for any tips,
gert