This could be further optimized by adding the rules
T operator*( T val, one_t ){ return( val ); }
T operator*( T val, minus_one_t ){ return( -val ); }
T operator+( T val, zero_t ){ return( val ); }
-----
Of course you could do the others as well.
T operator/( T val, one_t ){ return( val ); }
T operator/( T val, minus_one_t ){ return( -val ); }
T operator-( T val, zero_t ){ return( val ); }
zero_t operator*( T val, zero_t ){ return( zero_t ); }
T operator/( T val, zero_t ) { throw divide_by_zero; }
The nice thing is that if you are copying a formula into some code you don't have to
do the optimizations by hand.
-Gary-
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost