Sign of gcd in rational.hpp

The invariant check in rational.hpp assumes that the sign of gcd is positive: template <typename IntType> inline bool rational<IntType>::test_invariant() const { return ( this->den > int_type(0) ) && ( math::gcd(this->num, this->den) == int_type(1) ); } For built-in types, math::gcd is indeed specialized in such a way that it is always positive. For user defined IntType, math::gcd, however, does not ensure a special sign. Does this mean that the user has to specialize boost::math::gcd<IntType>? I did not find such an requirement in http://www.boost.org/doc/libs/1_43_0/libs/rational/rational.html#Integer%20T... Or should this better be solved in rational.hpp, e.g. by adding some function abs(gcd) or some test is_unit(gcd)? Helmut -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser
participants (1)
-
Helmut Zeisel