Boost logo

Boost :

Subject: [boost] Boost.Rational: improve operator+= and operator-= for param_type
From: Morwenn Ed (morwenn29_at_[hidden])
Date: 2014-05-25 09:47:14

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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at