1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// 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/ext/std/integral_constant.hpp>
#include <boost/hana/assert.hpp>
#include <boost/hana/equal.hpp>
#include <boost/hana/eval_if.hpp>
#include <boost/hana/functional/always.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/hana/not.hpp>
#include <boost/hana/tuple.hpp>
#include <laws/base.hpp>
#include <laws/logical.hpp>
#include <type_traits>
namespace hana = boost::hana;
int main() {
// eval_if
{
auto t = hana::test::ct_eq<3>{};
auto e = hana::test::ct_eq<4>{};
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::eval_if(std::true_type{}, hana::always(t), hana::always(e)),
t
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::eval_if(std::false_type{}, hana::always(t), hana::always(e)),
e
));
}
// not_
{
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::not_(std::true_type{}),
std::false_type{}
));
BOOST_HANA_CONSTANT_CHECK(hana::equal(
hana::not_(std::false_type{}),
std::true_type{}
));
}
auto ints = hana::make_tuple(
std::integral_constant<int, -2>{},
std::integral_constant<int, 0>{},
std::integral_constant<int, 1>{},
std::integral_constant<int, 3>{}
);
auto bools = hana::make_tuple(std::true_type{}, std::false_type{});
// laws
hana::test::TestLogical<hana::ext::std::integral_constant_tag<int>>{ints};
hana::test::TestLogical<hana::ext::std::integral_constant_tag<bool>>{bools};
}
|