Is it possible(another one!) to 'define' an operator() from a function pointer?
I was wondering if the above was possible since it would reduce some layers of redirection in my code.
Code:
class Operator : public token
{
public:
//Operator(std::string input);
Operator(std::string input,int p,Assoc a);
Operator(){};//DUMMY..remove later
int prec;
Assoc assoc;
void operator()(std::vector<token*>& instack);
};
Constructor:
Code:
Operator::Operator(std::string input,int p,Assoc a)
{
this->type=op;
this->raw=input;
this->prec = p;
this->assoc = a;
&operator() = opmap[input];
//This is erroneous ..but illustrates what I'd like to do.(Note that there isn't any mismatch
//in type of the functions. Also, opmap is map mapping strings to function pointers.)
}
What I have now for the operator()
Code:
void Operator::operator()(std::vector<token*>& instack)
{
(opmap[this->raw])(instack);
}