diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/example/ext/std/ratio | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/example/ext/std/ratio')
3 files changed, 91 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp b/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp new file mode 100644 index 000000000..7bcdbbd3f --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/arithmetic.cpp @@ -0,0 +1,57 @@ +// 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() { } diff --git a/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp b/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp new file mode 100644 index 000000000..05d64de32 --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/comparable.cpp @@ -0,0 +1,17 @@ +// 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() { } diff --git a/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp b/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp new file mode 100644 index 000000000..7764bb12a --- /dev/null +++ b/src/boost/libs/hana/example/ext/std/ratio/orderable.cpp @@ -0,0 +1,17 @@ +// 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() { } |