Boost.Rational: improve operator+= and operator-= for param_type
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.
3838
Age (days ago)
3838
Last active (days ago)
0 comments
1 participants
participants (1)
-
Morwenn Ed