YSTest: integral_constant.hpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

integral_constant.hpp
浏览该文件的文档.
1 /*
2 © 2012, 2015-2016, 2018-2019 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_integral_constant_hpp_
29 #define YB_INC_ystdex_integral_constant_hpp_ 1
30
31 #include "../ydef.h" // for <type_traits>, __cpp_lib_bool_constant,
32 // std::conditional;
33
34 namespace ystdex
35 {
36
68 inline namespace cpp2011
69 {
70
72
73 using std::integral_constant;
74 using std::true_type;
75 using std::false_type;
77
78 } // inline namespace cpp2011;
79
80
82
83
88 #define YB_Impl_DeclIntT(_n, _t) \
89 template<_t _vInt> \
90 using _n = integral_constant<_t, _vInt>;
91 #define YB_Impl_DeclIntTDe(_t) YB_Impl_DeclIntT(_t##_, _t)
92
93 YB_Impl_DeclIntTDe(bool)
94 YB_Impl_DeclIntTDe(char)
95 YB_Impl_DeclIntTDe(int)
96 YB_Impl_DeclIntT(llong_, long long)
97 YB_Impl_DeclIntTDe(long)
98 YB_Impl_DeclIntTDe(short)
99 YB_Impl_DeclIntT(ullong_, unsigned long long)
100 YB_Impl_DeclIntT(ulong_, unsigned long)
101 YB_Impl_DeclIntT(uint_, unsigned)
102 YB_Impl_DeclIntT(ushort_, unsigned short)
103 YB_Impl_DeclIntTDe(size_t)
104 YB_Impl_DeclIntTDe(ptrdiff_t)
105
106 #undef YB_Impl_DeclIntTDe
107 #undef YB_Impl_DeclIntT
108
109 using true_ = bool_<true>;
110 using false_ = bool_<false>;
112
113
118 inline namespace cpp2017
119 {
120
127 #if __cpp_lib_bool_constant >= 201505L
128 using std::bool_constant;
129 #else
130 template<bool _b>
131 using bool_constant = bool_<_b>;
132 #endif
133
134
135 } // inline namespace cpp2017;
136
137
148
150 template<class...>
151 struct and_;
152
153 template<>
154 struct and_<> : true_
155 {};
156
157 template<class _b1>
158 struct and_<_b1> : _b1
159 {};
160
162 template<class _b1, class _b2, class... _bn>
163 struct and_<_b1, _b2, _bn...>
164 : std::conditional<_b1::value, and_<_b2, _bn...>, _b1>::type
165 {};
167
168
170
171 template<class...>
172 struct or_;
173
174 template<>
175 struct or_<> : false_
176 {};
177
178 template<class _b1>
179 struct or_<_b1> : _b1
180 {};
181
183 template<class _b1, class _b2, class... _bn>
184 struct or_<_b1, _b2, _bn...>
185 : std::conditional<_b1::value, _b1, or_<_b2, _bn...>>::type
186 {};
188
189
191 template<class _b>
192 struct not_ : bool_<!_b::value>
193 {};
195
196
198
199 template<class... _bSeq>
201 struct nand_ : not_<and_<_bSeq...>>
202 {};
203
205 template<class... _bSeq>
206 struct nor_ : not_<or_<_bSeq...>>
207 {};
209
210
211
212 inline namespace cpp2017
213 {
214
222 template<class... _b>
223 using conjunction = and_<_b...>;
224
225 template<class... _b>
226 using disjunction = or_<_b...>;
227
228 template<class _b>
229 using negation = not_<_b>;
231
232 } // inline namespace cpp2017;
233
234 } // namespace ystdex;
235
236 #endif
237
YB_Impl_DeclIntT
#define YB_Impl_DeclIntT(_n, _t)
整数常量类型别名。
Definition: integral_constant.hpp:88
YB_Impl_DeclIntTDe
#define YB_Impl_DeclIntTDe(_t)
Definition: integral_constant.hpp:91
ystdex::and_< _b1 >
Definition: integral_constant.hpp:159
ystdex::bool_
integral_constant< bool, _vInt > bool_
Definition: integral_constant.hpp:93
ystdex::ullong_
integral_constant< unsigned long long, _vInt > ullong_
Definition: integral_constant.hpp:99
ystdex::or_
逻辑或。
Definition: integral_constant.hpp:172
ystdex::nand_
逻辑与非。
Definition: integral_constant.hpp:202
ystdex::and_<>
Definition: integral_constant.hpp:155
ystdex::or_< _b1 >
Definition: integral_constant.hpp:180
ystdex::true_
bool_< true > true_
Definition: integral_constant.hpp:109
ystdex::ushort_
integral_constant< unsigned short, _vInt > ushort_
Definition: integral_constant.hpp:102
ystdex::cpp2017::bool_constant
bool_< _b > bool_constant
bool 常量。
Definition: integral_constant.hpp:131
ystdex::ulong_
integral_constant< unsigned long, _vInt > ulong_
Definition: integral_constant.hpp:100
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
ystdex::llong_
integral_constant< long long, _vInt > llong_
Definition: integral_constant.hpp:96
ystdex::not_
逻辑非。
Definition: integral_constant.hpp:193
ystdex::false_
bool_< false > false_
Definition: integral_constant.hpp:110
ystdex::uint_
integral_constant< unsigned, _vInt > uint_
Definition: integral_constant.hpp:101
ystdex::nor_
逻辑或非。
Definition: integral_constant.hpp:207
ystdex::and_
逻辑操作元函数。
Definition: integral_constant.hpp:151
ystdex::or_<>
Definition: integral_constant.hpp:176