- lib:
boost/libs/rational
- repo:
boostorg/rational
- commit:
d1cd08fc
, 2017-03-27
<boost/rational.hpp>
class bad_rational : public std::domain_error;
template <typename IntType>
class rational;
constexpr rational()
- 0/1constexpr rational(n)
- n/1rational(num, den)
- num/den, normalizedconstexpr explicit rational(rational<NewType> const &)
operator=(n) -> rational&
- n/1assign(num, den) -> rational&
- num/den
+=
,-=
,*=
,/=
,++
,--
,!
,bool
,<
,==
,>
constexpr numerator() const -> const IntType&
constexpr denominator() const -> const IntType&
<=
,==
,+
,-
,*
,/
,++
,--
Both forrational
andIntType
.
<<
and>>
constexpr rational_cast<T>(const rational<IntType>&) -> T
abs(const rational<IntType>&) -> rational<IntType>
Keep normalized if possible.
Throw bad_rational
whenever encounter error.
<boost/config.hpp>
.<boost/detail/workaround.hpp>
.
<boost/utility/enable_if.hpp>
<boost/operators.hpp>
- Support non-function operators.<boost/call_traits.hpp>
<boost/assert.hpp>
<boost/integer/common_factor_rt.hpp>
- Run-time GCD/LCM functions
<boost/static_assert.hpp>
<boost/type_traits/is_convertible.hpp>
<boost/type_traits/is_class.hpp>
<boost/type_traits/is_same.hpp>
<boost/throw_exception.hpp>
- Proposals
- n3611 - A Rational Number Library for C++ (not accepted).