Ratio Functions

#include <xo/ratio/ratio.hpp>
template<typename Int1, typename Int2>
constexpr auto xo::ratio::make_ratio(Int1 n, Int2 d = 1) -> ratio<std::common_type_t<Int1, Int2>>

create a ratio in lowest terms from two integers

group ratio-arithmetic

Functions

template<typename Ratio1, typename Ratio2>
inline constexpr auto operator+(const Ratio1 &x, const Ratio2 &y)

add two ratios.

One argument may be a non-ratio type if it can be promoted to a ratio

template<typename Ratio1, typename Ratio2>
inline constexpr auto operator-(const Ratio1 &x, const Ratio2 &y)

subtract two ratios.

One argument may be a non-ratio type if it can be promoted to a ratio

template<typename Ratio1, typename Ratio2>
inline constexpr auto operator*(const Ratio1 &x, const Ratio2 &y)

multiply two ratios

One argument may be a non-ratio type if it can be promoted to a ratio

template<typename Ratio1, typename Ratio2>
inline constexpr auto operator/(const Ratio1 &x, const Ratio2 &y)

divide two ratios

One argument may be a non-ratio type if it can be promoted to a ratio

group ratio-3way-compare

Functions

template<typename Ratio1, typename Ratio2>
inline constexpr bool operator==(const Ratio1 &x, const Ratio2 &y)

compare two ratios for equality

One argument may be a non-ratio type if it can be promoted to a ratio

template<typename Ratio1, typename Ratio2>
inline constexpr auto operator<=>(const Ratio1 &x, const Ratio2 &y)

compare two ratios

One argument may be a non-ratio type if it can be promoted to a ratio