Boost.Hana  1.5.0
Your standard library for metaprogramming
std::ratio< Num, Denom > Class Template Reference

Description

template<std::intmax_t Num, std::intmax_t Denom>
class std::ratio< Num, Denom >

Adaptation of std::ratio for Hana.

Modeled concepts

  1. Comparable
    std::ratios are compared for equality using std::ratio_equal.
    // Copyright Louis Dionne 2013-2017
    // Distributed under the Boost Software License, Version 1.0.
    // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
    #include <ratio>
    namespace hana = boost::hana;
    int main() { }
  2. Orderable
    std::ratios are ordered using std::ratio_less.
    // Copyright Louis Dionne 2013-2017
    // Distributed under the Boost Software License, Version 1.0.
    // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
    #include <ratio>
    namespace hana = boost::hana;
    int main() { }
  3. Monoid, Group, Ring, and EuclideanRing
    std::ratios are added, subtracted, multiplied and divided using std::ratio_add, std::ratio_subtract, std::ratio_multiply and std::ratio_divide, respectively. Furthermore, the neutral element for the additive operation is std::ratio<0, 1>{}, and the neutral element for the multiplicative operation is std::ratio<1, 1>{}.
    // Copyright Louis Dionne 2013-2017
    // Distributed under the Boost Software License, Version 1.0.
    // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
    #include <ratio>
    namespace hana = boost::hana;
    ));
    ));
    ));
    ));
    // The mod of two ratios is always 0, because they can always be
    // divided without remainder.
    ));
    hana::zero<hana::ext::std::ratio_tag>(),
    ));
    hana::one<hana::ext::std::ratio_tag>(),
    ));
    int main() { }