]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/logical.cpp
125c2a5693c7f8f9e3c041ad82bc293c01ef4607
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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/concept/logical.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/eval_if.hpp>
9 #include <boost/hana/functional/always.hpp>
10 #include <boost/hana/not.hpp>
11 #include <boost/hana/tuple.hpp>
12 #include <boost/hana/while.hpp>
14 #include <laws/logical.hpp>
17 namespace hana
= boost::hana
;
21 hana::test::TestLogical
<bool>{hana::make_tuple(true, false)};
25 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
26 hana::eval_if(true, hana::always(1), hana::always(2)),
30 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
31 hana::eval_if(false, hana::always(1), hana::always(2)),
38 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(true), false));
39 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(false), true));
44 auto less_than
= [](auto n
) {
45 return [n
](auto v
) { return v
.size() < n
; };
48 v
.push_back(v
.size());
52 BOOST_HANA_RUNTIME_CHECK(hana::equal(
53 hana::while_(less_than(0u), std::vector
<int>{}, f
),
57 BOOST_HANA_RUNTIME_CHECK(hana::equal(
58 hana::while_(less_than(1u), std::vector
<int>{}, f
),
62 BOOST_HANA_RUNTIME_CHECK(hana::equal(
63 hana::while_(less_than(2u), std::vector
<int>{}, f
),
64 std::vector
<int>{0, 1}
67 BOOST_HANA_RUNTIME_CHECK(hana::equal(
68 hana::while_(less_than(3u), std::vector
<int>{}, f
),
69 std::vector
<int>{0, 1, 2}
72 BOOST_HANA_RUNTIME_CHECK(hana::equal(
73 hana::while_(less_than(4u), std::vector
<int>{}, f
),
74 std::vector
<int>{0, 1, 2, 3}
77 // Make sure it can be called with an lvalue state:
79 BOOST_HANA_RUNTIME_CHECK(hana::equal(
80 hana::while_(less_than(4u), v
, f
),
81 std::vector
<int>{0, 1, 2, 3}