On Wed, 16 May 2001, Richard B. Kreckel wrote:
On Wed, 16 May 2001, Pearu Peterson wrote:
It seems to me that one has to define for each class, that redefines basic::precedence, also the get_precedence() function. Clearly it is not C++ way, but may be it is due to that basic::precedence is defined static. Sorry, but right now I don't have any idea how to fix it...
Thanks Pearu for the bugreport. Your analysis is correct.
Christian, we've had the same trouble when we tried to make default_overall_coeff() an inline function in class expairseq returning a protected static ex(1) or ex(0) respectively for classes mul and add. This just doesn't work with static member variables. All alternatives which come to my mind are either preprocessor-based or replicate data and either way as ugly as sin. Any really good suggestion?
I played a bit with possible solutions (assuming static precedence) and it seems that simplest solution is inserting the following line public: unsigned get_precedence(void) const {return precedence;} to the macro GINAC_DECLARE_REGISTERED_CLASS (Note that then there is little reason to keep basic::get_precedence()) Optimal (for the compiler but not for the programmer, I guess) solution is: When redefining precedence, redefine also get_precedence() in derived class. What do you think? Pearu