I was wondering if the above was possible since it would reduce some layers of redirection in my code.
Constructor: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); };
What I have now for the operator()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.) }
Code:void Operator::operator()(std::vector<token*>& instack) { (opmap[this->raw])(instack); }



LinkBack URL
About LinkBacks


