| 312 | } |
| 313 | template <class T> |
| 314 | BOOST_CXX14_CONSTEXPR typename boost::enable_if_c<rational_detail::is_compatible_integer<T, IntType>::value, rational&>::type operator/= (const T& i) |
| 315 | { |
| 316 | // Avoid repeated construction |
| 317 | IntType const zero(0); |
| 318 | |
| 319 | if(i == zero) BOOST_THROW_EXCEPTION(bad_rational()); |
| 320 | if(num == zero) return *this; |
| 321 | |
| 322 | // Avoid overflow and preserve normalization |
| 323 | IntType const gcd = integer::gcd(num, static_cast<IntType>(i)); |
| 324 | num /= gcd; |
| 325 | den *= i / gcd; |
| 326 | |
| 327 | if(den < zero) { |
| 328 | num = -num; |
| 329 | den = -den; |
| 330 | } |
| 331 | |
| 332 | return *this; |
| 333 | } |
| 334 | |
| 335 | // Increment and decrement |
| 336 | BOOST_CXX14_CONSTEXPR const rational& operator++() { num += den; return *this; } |
nothing calls this directly
no test coverage detected