Boost.Hana: std::ratio< Num, Denom > Class Template Reference

| Boost.Hana 1.7.1 Your standard library for metaprogramming |

std::ratio< Num, Denom > Class Template Reference
External adapters » Standard library adapters

## 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::ratio`s 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 <boost/hana/assert.hpp>
   #include <boost/hana/equal.hpp>
   #include <boost/hana/ext/std/ratio.hpp>
   #include <boost/hana/not_equal.hpp>
   #include <ratio>
   namespace hana = boost::hana;
   BOOST_HANA_CONSTANT_CHECK(hana::equal(std::ratio<3, 4>{}, std::ratio<15, 20>{}));
   BOOST_HANA_CONSTANT_CHECK(hana::not_equal(std::ratio<3, 4>{}, std::ratio<3, 5>{}));
   int main() { }
   assert.hpp
   Defines macros to perform different kinds of assertions.
   std::ratio
   Adaptation of std::ratio for Hana.
   Definition: ratio.hpp:58
   equal.hpp
   Defines boost::hana::equal.
   boost::hana::equal
   constexpr auto equal
   Returns a Logical representing whether x is equal to y.
   Definition: equal.hpp:64
   boost::hana::not_equal
   constexpr auto not_equal
   Returns a Logical representing whether x is not equal to y.
   Definition: not_equal.hpp:54
   BOOST_HANA_CONSTANT_CHECK
   #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
   boost::hana
   Namespace containing everything in the library.
   Definition: accessors.hpp:20
   not_equal.hpp
   Defines boost::hana::not_equal.
   ratio.hpp
   Adapts std::ratio for use with Hana.
2. `Orderable`
   `std::ratio`s 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 <boost/hana/assert.hpp>
   #include <boost/hana/ext/std/ratio.hpp>
   #include <boost/hana/less.hpp>
   #include <boost/hana/less_equal.hpp>
   #include <ratio>
   namespace hana = boost::hana;
   BOOST_HANA_CONSTANT_CHECK(hana::less(std::ratio<3, 12>{}, std::ratio<5, 12>{}));
   BOOST_HANA_CONSTANT_CHECK(hana::less_equal(std::ratio<6, 12>{}, std::ratio<4, 8>{}));
   int main() { }
   boost::hana::less_equal
   constexpr auto less_equal
   Returns a Logical representing whether x is less than or equal to y.
   Definition: less_equal.hpp:38
   boost::hana::less
   constexpr auto less
   Returns a Logical representing whether x is less than y.
   Definition: less.hpp:37
   less.hpp
   Defines boost::hana::less.
   less_equal.hpp
   Defines boost::hana::less_equal.
3. `Monoid`, `Group`, `Ring`, and `EuclideanRing`
   `std::ratio`s 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 <boost/hana/assert.hpp>
   #include <boost/hana/div.hpp>
   #include <boost/hana/equal.hpp>
   #include <boost/hana/ext/std/ratio.hpp>
   #include <boost/hana/minus.hpp>
   #include <boost/hana/mod.hpp>
   #include <boost/hana/mult.hpp>
   #include <boost/hana/one.hpp>
   #include <boost/hana/plus.hpp>
   #include <boost/hana/zero.hpp>
   #include <ratio>
   namespace hana = boost::hana;
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::plus(std::ratio<5, 3>{}, std::ratio<3, 12>{}),
   std::ratio<23, 12>{}
   ));
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::minus(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
   std::ratio<56, 39>{}
   ));
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::mult(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
   std::ratio<15, 39>{}
   ));
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::div(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
   std::ratio<65, 9>{}
   ));
   // The mod of two ratios is always 0, because they can always be
   // divided without remainder.
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::mod(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
   std::ratio<0>{}
   ));
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::zero<hana::ext::std::ratio_tag>(),
   std::ratio<0>{}
   ));
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::one<hana::ext::std::ratio_tag>(),
   std::ratio<1>{}
   ));
   int main() { }
   div.hpp
   Defines boost::hana::div.
   boost::hana::div
   constexpr auto div
   Generalized integer division.
   Definition: div.hpp:43
   boost::hana::mod
   constexpr auto mod
   Generalized integer modulus.
   Definition: mod.hpp:46
   boost::hana::minus
   constexpr auto minus
   Subtract two elements of a group.
   Definition: minus.hpp:51
   boost::hana::plus
   constexpr auto plus
   Associative binary operation on a Monoid.
   Definition: plus.hpp:47
   boost::hana::mult
   constexpr auto mult
   Associative operation of a Ring.
   Definition: mult.hpp:47
   minus.hpp
   Defines boost::hana::minus.
   mod.hpp
   Defines boost::hana::mod.
   mult.hpp
   Defines boost::hana::mult.
   one.hpp
   Defines boost::hana::one.
   plus.hpp
   Defines boost::hana::plus.
   zero.hpp
   Defines boost::hana::zero.