File size: 1,796 Bytes
8ae5fc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
#include <metal.hpp>

#include "example.hpp"

/// [bool]
using true_ = metal::_1;
using false_ = metal::_2;
/// [bool]

IS_SAME(metal::invoke<true_, true_, false_>, true_);
IS_SAME(metal::invoke<true_, false_, true_>, false_);
IS_SAME(metal::invoke<false_, true_, false_>, false_);
IS_SAME(metal::invoke<false_, false_, true_>, true_);

HIDE(
/// [not_expr]
template<class b>
using not_ = metal::invoke<b, false_, true_>;

IS_SAME(not_<true_>, false_);
IS_SAME(not_<false_>, true_);
/// [not_expr]
)

/// [not]
using not_ = metal::bind<
    metal::lambda<metal::invoke>,
    metal::_1, metal::always<false_>, metal::always<true_>
>;

IS_SAME(metal::invoke<not_, true_>, false_);
IS_SAME(metal::invoke<not_, false_>, true_);
/// [not]

/// [and]
// 位x 位y x y x
using and_ = metal::bind<
    metal::lambda<metal::invoke>,
    metal::_1, metal::_2, metal::_1
>;

IS_SAME(metal::invoke<and_, true_, true_>, true_);
IS_SAME(metal::invoke<and_, true_, false_>, false_);
IS_SAME(metal::invoke<and_, false_, true_>, false_);
IS_SAME(metal::invoke<and_, false_, false_>, false_);
/// [and]

/// [or]
// 位x 位y x x y
using or_ = metal::bind<
    metal::lambda<metal::invoke>,
    metal::_1, metal::_1, metal::_2
>;

IS_SAME(metal::invoke<or_, true_, true_>, true_);
IS_SAME(metal::invoke<or_, true_, false_>, true_);
IS_SAME(metal::invoke<or_, false_, true_>, true_);
IS_SAME(metal::invoke<or_, false_, false_>, false_);
/// [or]

/// [xor]
// 位x 位y x (not y) y
using xor_ = metal::bind<
    metal::lambda<metal::invoke>,
    metal::_1, metal::bind<not_, metal::_2>, metal::_2
>;

IS_SAME(metal::invoke<xor_, true_, true_>, false_);
IS_SAME(metal::invoke<xor_, true_, false_>, true_);
IS_SAME(metal::invoke<xor_, false_, true_>, true_);
IS_SAME(metal::invoke<xor_, false_, false_>, false_);
/// [xor]