-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_booltyp.h
More file actions
188 lines (155 loc) · 3.54 KB
/
_booltyp.h
File metadata and controls
188 lines (155 loc) · 3.54 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef __BOOLTYP_H
#define __BOOLTYP_H
// Copyright David Lawrence Bien 1997 - 2021.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt).
// _booltyp.h
// Define the boolean types std::true_type and std::false_type and some related utilities.
#include <type_traits>
#ifdef _MSC_VER
#define __INLINE __inline
#else //_MSC_VER
#define __INLINE inline
#endif //_MSC_VER
__BIENUTIL_BEGIN_NAMESPACE
#ifdef __GNUC__ // doesn't like templates declared like this.
// Type->boolean functions:
template < class t_TyBoolean >
bool __FTrue( t_TyBoolean );
template <>
__INLINE bool __FTrue( std::false_type )
{
return false;
}
template <>
__INLINE bool __FTrue( std::true_type )
{
return true;
}
template < class t_TyBoolean >
bool __FFalse( t_TyBoolean );
template <>
__INLINE bool __FFalse( std::true_type )
{
return false;
}
template <>
__INLINE bool __FFalse( std::false_type )
{
return true;
}
#endif //!__GNUC__
// Type->boolean types:
template < class _TyF > struct __type_to_bool
{
static const bool ms_cfValue = true;
};
template < > struct __type_to_bool< std::false_type >
{
static const bool ms_cfValue = false;
};
// Boolean->type types:
template < bool _f > struct __boolean_type
{
typedef std::true_type _type;
};
template <>
struct __boolean_type<false>
{
typedef std::false_type _type;
};
// Boolean operations:
template < bool t_fBoolean >
struct __boolean_not
{
static const bool ms_cfValue = false;
};
template < >
struct __boolean_not< false >
{
static const bool ms_cfValue = true;
};
template < bool t_fBoolean1, bool t_fBoolean2 >
struct __boolean_and
{
static const bool ms_cfValue = false;
};
template < >
struct __boolean_and< true, true >
{
static const bool ms_cfValue = true;
};
template < bool t_fBoolean1, bool t_fBoolean2 >
struct __boolean_or
{
static const bool ms_cfValue = true;
};
template < >
struct __boolean_or< false, false >
{
static const bool ms_cfValue = false;
};
template < bool t_fBoolean1, bool t_fBoolean2 >
struct __boolean_equals
{
static const bool ms_cfValue = false;
};
template < >
struct __boolean_equals< false, false >
{
static const bool ms_cfValue = true;
};
template < >
struct __boolean_equals< true, true >
{
static const bool ms_cfValue = true;
};
// Boolean type operations:
template < class t_TyBoolean >
struct __booltyp_not
{
typedef std::false_type _value;
};
template < >
struct __booltyp_not< std::false_type >
{
typedef std::true_type _value;
};
template < class t_TyBool1, class t_TyBool2 >
struct __booltyp_and
{
typedef std::false_type _value;
};
template < >
struct __booltyp_and< std::true_type, std::true_type >
{
typedef std::true_type _value;
};
template < class t_TyBool1, class t_TyBool2 >
struct __booltyp_or
{
typedef std::true_type _value;
};
template < >
struct __booltyp_or< std::false_type, std::false_type >
{
typedef std::false_type _value;
};
template < class t_TyBool1, class t_TyBool2 >
struct __booltyp_equals
{
typedef std::false_type _value;
};
template < >
struct __booltyp_equals< std::false_type, std::false_type >
{
typedef std::true_type _value;
};
template < >
struct __booltyp_equals< std::true_type, std::true_type >
{
typedef std::true_type _value;
};
__BIENUTIL_END_NAMESPACE
#endif //__BOOLTYP_H