Boost.Hana  1.7.1
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() { }
    Defines macros to perform different kinds of assertions.
    Adaptation of std::ratio for Hana.
    Definition: ratio.hpp:58
    Defines boost::hana::equal.
    constexpr auto equal
    Returns a Logical representing whether x is equal to y.
    Definition: equal.hpp:64
    constexpr auto not_equal
    Returns a Logical representing whether x is not equal to y.
    Definition: not_equal.hpp:54
    #define BOOST_HANA_CONSTANT_CHECK(...)
    Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...
    Definition: assert.hpp:239
    Namespace containing everything in the library.
    Definition: accessors.hpp:20
    Defines boost::hana::not_equal.
    Adapts std::ratio for use with Hana.
  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() { }
    constexpr auto less_equal
    Returns a Logical representing whether x is less than or equal to y.
    Definition: less_equal.hpp:38
    constexpr auto less
    Returns a Logical representing whether x is less than y.
    Definition: less.hpp:37
    Defines boost::hana::less.
    Defines boost::hana::less_equal.
  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() { }
    Defines boost::hana::div.
    constexpr auto div
    Generalized integer division.
    Definition: div.hpp:43
    constexpr auto mod
    Generalized integer modulus.
    Definition: mod.hpp:46
    constexpr auto minus
    Subtract two elements of a group.
    Definition: minus.hpp:51
    constexpr auto plus
    Associative binary operation on a Monoid.
    Definition: plus.hpp:47
    constexpr auto mult
    Associative operation of a Ring.
    Definition: mult.hpp:47
    Defines boost::hana::minus.
    Defines boost::hana::mod.
    Defines boost::hana::mult.
    Defines boost::hana::one.
    Defines boost::hana::plus.
    Defines boost::hana::zero.