I'm continuously getting errors saying "No matching call for function" while using boost::variant. Below is my code snippet.
struct Output {
int a;
float b;
}
typedef boost::variant<ClassA<X, Y>, ClassA<>> ClassAGeneric;
class Operation: public boost::static_visitor<Output>
{
public:
double d;
int a;
float b;
Output operator()(ClassA<X, Y> obj) const
{
obj.operate(d, a, b);
return (Output) {a, b};
}
Output operator()(ClassA<> obj) const
{
obj.operate(d, a, b);
return (Output) {a, b};
}
};
I'm getting this error in the obj.operate() call in the first operator() that is defined.
I tried the passing the templates as well like mentioned in the other answer, but I still see an error.
obj.operate<X,Y>(d,a,b);
Could somebody help me with this?
I could give the exact scenario as well here :
struct Output{
Row<size_t> predictions;
mat probabilities;
};
typedef boost::variant<RandomForest<GiniGain, RandomDimensionSelect>, RandomForest<>> RandomForestGeneric;
class Operation: public boost::static_visitor<Output>
{
public:
mat dataset;
Row<size_t> predictions;
mat probabilities;
Output operator()(RandomForest<GiniGain, RandomDimensionSelect> obj) const
{
obj.Classify(dataset, predictions, probabilities);
return (Output) {predictions, probabilities};
}
Output operator()(RandomForest<> obj) const
{
obj.Classify(dataset, predictions, probabilities);
return (Output) {predictions, probabilities};
}
};