rational: assert the denominator is nonzero on reduce

this placates clang-analyzer
This commit is contained in:
Danny Robson 2018-03-13 14:39:51 +11:00
parent 3a4f6ffce8
commit e0fb8e4e6b

View File

@ -17,6 +17,7 @@
#include "rational.hpp"
#include "maths.hpp"
#include "debug.hpp"
#include <cstdint>
@ -109,6 +110,7 @@ template <typename T>
rational<T>
rational<T>::reduced (void) const
{
CHECK_NEZ (d);
auto x = std::gcd (abs (n), abs (d));
return { n / x, d / x };