]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp
37b1e98f5e9d87dfb18edde4b5a11b5dea716b7d
[ceph.git] / ceph / src / boost / libs / hana / example / ext / std / ratio / arithmetic.cpp
1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/div.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/ext/std/ratio.hpp>
9 #include <boost/hana/minus.hpp>
10 #include <boost/hana/mod.hpp>
11 #include <boost/hana/mult.hpp>
12 #include <boost/hana/one.hpp>
13 #include <boost/hana/plus.hpp>
14 #include <boost/hana/zero.hpp>
15
16 #include <ratio>
17 namespace hana = boost::hana;
18
19
20 BOOST_HANA_CONSTANT_CHECK(hana::equal(
21 hana::plus(std::ratio<5, 3>{}, std::ratio<3, 12>{}),
22 std::ratio<23, 12>{}
23 ));
24
25 BOOST_HANA_CONSTANT_CHECK(hana::equal(
26 hana::minus(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
27 std::ratio<56, 39>{}
28 ));
29
30 BOOST_HANA_CONSTANT_CHECK(hana::equal(
31 hana::mult(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
32 std::ratio<15, 39>{}
33 ));
34
35 BOOST_HANA_CONSTANT_CHECK(hana::equal(
36 hana::div(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
37 std::ratio<65, 9>{}
38 ));
39
40 // The mod of two ratios is always 0, because they can always be
41 // divided without remainder.
42 BOOST_HANA_CONSTANT_CHECK(hana::equal(
43 hana::mod(std::ratio<5, 3>{}, std::ratio<3, 13>{}),
44 std::ratio<0>{}
45 ));
46
47 BOOST_HANA_CONSTANT_CHECK(hana::equal(
48 hana::zero<hana::ext::std::ratio_tag>(),
49 std::ratio<0>{}
50 ));
51
52 BOOST_HANA_CONSTANT_CHECK(hana::equal(
53 hana::one<hana::ext::std::ratio_tag>(),
54 std::ratio<1>{}
55 ));
56
57 int main() { }