25 May
2014
25 May
'14
1:47 p.m.
It is possible to provide an implementation of operator+=(param_type) and operator-=(param_type) for the rational class that could be more efficient than the current one: template <typename IntType> inline rational<IntType>& rational<IntType>::operator+= (param_type i) { num += i * den; return *this; }The operation should never denormalize the fraction. Actually, the same optimization is already used in operator++ and operator--. It allows not to convert the param_type into a rational before adding it. Morwenn.