Inside my class called AID, I have got three fitting curve functions: LastStateFitting, LinearCurveFitting and QuadCurveFitting. Another function choose which one is the most appropriate. I have stored pointer method inside a map (boost::unordered_map):
typedef enum predMethod{LAST, LINEAR, QUAD} predMethod;
predMethod method;
typedef double*(AID::*fitting)(double[3]);
double * LastStateFitting(double x[3]);
double * LinearCurveFitting(double x[3]);
double * QuadCurveFitting(double x[3]);
const boost::unordered_map<predMethod, fitting> fittingMap = map_list_of
(LAST, &AID::LastStateFitting)
(LINEAR, &AID::LinearCurveFitting)
(QUAD, &AID::QuadCurveFitting);
I don't understand how I can those functions. For now, I have done:
for ( int fit = LAST; fit != QUAD; fit++ )
{
predMethod pm = static_cast<predMethod>(fit);
double pred[3] = (*fittingMap.at(pm))(x);
But this gives me:
error: indirection requires pointer operand ('mapped_type' (aka 'double (AID::)(double *)') invalid) double pred[3] = (*fittingMap.at(pm))(x);
Thus my question is: how can one call a method pointer inside a map?
EDIT: a few post around a method pointer are already answered (here or here). But here, it still doesn't work because of the map container.h