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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314 | #pragma once
#include <type_traits><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <concepts><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <ranges><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <limits><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <functional><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
namespace uni {
namespace internal {
template<class R, class T>
concept convertibel_range = std::convertible_to<std::ranges::range_value_t<R>, T>;
template<class T, class V>
concept item_or_convertible_range = std::convertible_to<T, V> || convertibel_range<T, V>;
template<class Structure>
concept available =
requires () {
typename Structure;
};
template<
template<class...> class Structure,
class... TemplateParameters
>
concept available_with = available<Structure<TemplateParameters...>>;
template<class T> concept arithmetic = std::is_arithmetic_v<T>;
template<class T> concept pointer = std::is_pointer_v<T>;
template<class T> concept structural = std::is_class_v<T>;
template<class Large, class Small>
concept has_double_digits_of = (std::numeric_limits<Large>::digits == 2 * std::numeric_limits<Small>::digits);
template<class Large, class Small>
concept has_more_digits_than = (std::numeric_limits<Large>::digits > std::numeric_limits<Small>::digits);
template<class Large, class Small>
concept has_or_more_digits_than = (std::numeric_limits<Large>::digits >= std::numeric_limits<Small>::digits);
template<class T>
concept has_static_zero = requires { T::zero; };
template<class T>
concept has_static_one = requires { T::one; };
template<class L, class R = L>
concept weakly_bitand_calcurable = requires (L lhs, R rhs) { lhs & rhs; };
template<class L, class R = L>
concept weakly_bitor_calcurable = requires (L lhs, R rhs) { lhs | rhs; };
template<class L, class R = L>
concept weakly_bitxor_calcurable = requires (L lhs, R rhs) { lhs ^ rhs; };
template<class L, class R = L>
concept weakly_addable = requires (L lhs, R rhs) { lhs + rhs; };
template<class L, class R = L>
concept weakly_subtractable = requires (L lhs, R rhs) { lhs - rhs; };
template<class L, class R = L>
concept weakly_multipliable = requires (L lhs, R rhs) { lhs * rhs; };
template<class L, class R = L>
concept weakly_divisable = requires (L lhs, R rhs) { lhs / rhs; };
template<class L, class R = L>
concept weakly_remainder_calculable = requires (L lhs, R rhs) { lhs % rhs; };
template<class L, class R = L>
concept weakly_bitand_assignable = requires (L lhs, R rhs) { lhs += rhs; };
template<class L, class R = L>
concept weakly_bitor_assignable = requires (L lhs, R rhs) { lhs |= rhs; };
template<class L, class R = L>
concept weakly_bitxor_assignable = requires (L lhs, R rhs) { lhs ^= rhs; };
template<class L, class R = L>
concept weakly_addition_assignable = requires (L lhs, R rhs) { lhs += rhs; };
template<class L, class R = L>
concept weakly_subtraction_assignable = requires (L lhs, R rhs) { lhs -= rhs; };
template<class L, class R = L>
concept weakly_multipliation_assignalbe = requires (L lhs, R rhs) { lhs *= rhs; };
template<class L, class R = L>
concept weakly_division_assignable = requires (L lhs, R rhs) { lhs /= rhs; };
template<class L, class R = L>
concept weakly_remainder_assignable = requires (L lhs, R rhs) { lhs /= rhs; };
template<class L, class R = L>
concept bitand_calculable =
weakly_bitand_calcurable<L, R> &&
weakly_bitand_calcurable<std::invoke_result_t<std::bit_and<>&, L, R>, R> &&
weakly_bitand_calcurable<L, std::invoke_result_t<std::bit_and<>&, L, R>> &&
weakly_bitand_calcurable<std::invoke_result_t<std::bit_and<>&, L, R>, std::invoke_result_t<std::bit_and<>&, L, R>>;
template<class L, class R = L>
concept bitor_calculable =
weakly_bitor_calcurable<L, R> &&
weakly_bitor_calcurable<std::invoke_result_t<std::bit_or<>&, L, R>, R> &&
weakly_bitor_calcurable<L, std::invoke_result_t<std::bit_or<>&, L, R>> &&
weakly_bitor_calcurable<std::invoke_result_t<std::bit_or<>&, L, R>, std::invoke_result_t<std::bit_or<>&, L, R>>;
template<class L, class R = L>
concept bitxor_calculable =
weakly_bitxor_calcurable<L, R> &&
weakly_bitxor_calcurable<std::invoke_result_t<std::bit_xor<>&, L, R>, R> &&
weakly_bitxor_calcurable<L, std::invoke_result_t<std::bit_xor<>&, L, R>> &&
weakly_bitxor_calcurable<std::invoke_result_t<std::bit_xor<>&, L, R>, std::invoke_result_t<std::bit_xor<>&, L, R>>;
template<class L, class R = L>
concept addable =
weakly_addable<L, R> &&
weakly_addable<std::invoke_result_t<std::plus<>&, L, R>, R> &&
weakly_addable<L, std::invoke_result_t<std::plus<>&, L, R>> &&
weakly_addable<std::invoke_result_t<std::plus<>&, L, R>, std::invoke_result_t<std::plus<>&, L, R>>;
template<class L, class R = L>
concept subtractable =
weakly_subtractable<L, R> &&
weakly_subtractable<std::invoke_result_t<std::minus<>&, L, R>, R> &&
weakly_subtractable<L, std::invoke_result_t<std::minus<>&, L, R>> &&
weakly_subtractable<std::invoke_result_t<std::minus<>&, L, R>, std::invoke_result_t<std::minus<>&, L, R>>;
template<class L, class R = L>
concept multipliable =
weakly_multipliable<L, R> &&
weakly_multipliable<std::invoke_result_t<std::multiplies<>&, L, R>, R> &&
weakly_multipliable<L, std::invoke_result_t<std::multiplies<>&, L, R>> &&
weakly_multipliable<std::invoke_result_t<std::multiplies<>&, L, R>, std::invoke_result_t<std::multiplies<>&, L, R>>;
template<class L, class R = L>
concept divisable =
weakly_divisable<L, R> &&
weakly_divisable<std::invoke_result_t<std::divides<>&, L, R>, R> &&
weakly_divisable<L, std::invoke_result_t<std::divides<>&, L, R>> &&
weakly_divisable<std::invoke_result_t<std::divides<>&, L, R>, std::invoke_result_t<std::divides<>&, L, R>>;
template<class L, class R = L>
concept remainder_calculable =
weakly_remainder_calculable<L, R> &&
weakly_remainder_calculable<std::invoke_result_t<std::modulus<>&, L, R>, R> &&
weakly_remainder_calculable<L, std::invoke_result_t<std::modulus<>&, L, R>> &&
weakly_remainder_calculable<std::invoke_result_t<std::modulus<>&, L, R>, std::invoke_result_t<std::modulus<>&, L, R>>;
template<class L, class R = L>
concept bitand_assignable =
weakly_bitand_assignable<L, R> &&
weakly_bitand_assignable<std::invoke_result_t<std::bit_and<>&, L, R>, R> &&
weakly_bitand_assignable<L, std::invoke_result_t<std::bit_and<>&, L, R>> &&
weakly_bitand_assignable<std::invoke_result_t<std::bit_and<>&, L, R>, std::invoke_result_t<std::bit_and<>&, L, R>>;
template<class L, class R = L>
concept bitor_assignable =
weakly_bitor_calcurable<L, R> &&
weakly_bitor_calcurable<std::invoke_result_t<std::bit_or<>&, L, R>, R> &&
weakly_bitor_calcurable<L, std::invoke_result_t<std::bit_or<>&, L, R>> &&
weakly_bitor_calcurable<std::invoke_result_t<std::bit_or<>&, L, R>, std::invoke_result_t<std::bit_or<>&, L, R>>;
template<class L, class R = L>
concept bitxor_assignable =
weakly_bitxor_calcurable<L, R> &&
weakly_bitxor_calcurable<std::invoke_result_t<std::bit_xor<>&, L, R>, R> &&
weakly_bitxor_calcurable<L, std::invoke_result_t<std::bit_xor<>&, L, R>> &&
weakly_bitxor_calcurable<std::invoke_result_t<std::bit_xor<>&, L, R>, std::invoke_result_t<std::bit_xor<>&, L, R>>;
template<class L, class R = L>
concept addition_assignable =
weakly_addition_assignable<L, R> &&
weakly_addition_assignable<std::remove_cvref_t<std::invoke_result_t<std::plus<>&, L, R>>, R> &&
weakly_addition_assignable<L, std::invoke_result_t<std::plus<>&, L, R>> &&
weakly_addition_assignable<std::remove_cvref_t<std::invoke_result_t<std::plus<>&, L, R>>, std::invoke_result_t<std::plus<>&, L, R>>;
template<class L, class R = L>
concept subtraction_assignable =
weakly_subtraction_assignable<L, R> &&
weakly_subtraction_assignable<std::remove_cvref_t<std::invoke_result_t<std::minus<>&, L, R>>, R> &&
weakly_subtraction_assignable<L, std::invoke_result_t<std::minus<>&, L, R>> &&
weakly_subtraction_assignable<std::remove_cvref_t<std::invoke_result_t<std::minus<>&, L, R>>, std::invoke_result_t<std::minus<>&, L, R>>;
template<class L, class R = L>
concept multipliation_assignalbe =
weakly_multipliation_assignalbe<L, R> &&
weakly_multipliation_assignalbe<std::remove_cvref_t<std::invoke_result_t<std::multiplies<>&, L, R>>, R> &&
weakly_multipliation_assignalbe<L, std::invoke_result_t<std::multiplies<>&, L, R>> &&
weakly_multipliation_assignalbe<std::remove_cvref_t<std::invoke_result_t<std::multiplies<>&, L, R>>, std::invoke_result_t<std::multiplies<>&, L, R>>;
template<class L, class R = L>
concept division_assignable =
weakly_division_assignable<L, R> &&
weakly_division_assignable<std::remove_cvref_t<std::invoke_result_t<std::divides<>&, L, R>>, R> &&
weakly_division_assignable<L, std::invoke_result_t<std::divides<>&, L, R>> &&
weakly_division_assignable<std::remove_cvref_t<std::invoke_result_t<std::divides<>&, L, R>>, std::invoke_result_t<std::divides<>&, L, R>>;
template<class L, class R = L>
concept remainder_assignable =
weakly_remainder_assignable<L, R> &&
weakly_remainder_assignable<std::remove_cvref_t<std::invoke_result_t<std::modulus<>&, L, R>>, R> &&
weakly_remainder_assignable<L, std::invoke_result_t<std::modulus<>&, L, R>> &&
weakly_remainder_assignable<std::remove_cvref_t<std::invoke_result_t<std::modulus<>&, L, R>>, std::invoke_result_t<std::modulus<>&, L, R>>;
template<class T>
concept weakly_incrementable =
std::movable<T> &&
requires (T v) {
{ ++v } -> std::same_as<T&>;
v++;
};
template<class T>
concept weakly_decrementable =
std::movable<T> &&
requires (T v) {
{ --v } -> std::same_as<T&>;
v--;
};
template<class T>
concept incrementable =
std::regular<T> &&
weakly_incrementable<T> &&
requires (T v) {
{ v++ } -> std::same_as<T>;
};
template<class T>
concept decrementable =
std::regular<T> &&
weakly_decrementable<T> &&
requires (T v) {
{ v-- } -> std::same_as<T>;
};
template<class L, class R = L>
concept weakly_arithmetic_operable =
weakly_addable<L, R> &&
weakly_subtractable<L, R> &&
weakly_multipliable<L, R> &&
weakly_divisable<L, R>;
template<class L, class R = L>
concept weakly_arithmetic_operation_assignable =
weakly_addition_assignable<L, R> &&
weakly_subtraction_assignable<L, R> &&
weakly_multipliation_assignalbe<L, R> &&
weakly_division_assignable<L, R>;
template<class L, class R = L>
concept arithmetic_operable =
weakly_arithmetic_operable<L, R> &&
addable<L, R> &&
subtractable<L, R> &&
multipliable<L, R> &&
divisable<L, R>;
template<class L, class R = L>
concept arithmetic_operation_assignable =
weakly_arithmetic_operation_assignable<L, R> &&
addition_assignable<L, R> &&
subtraction_assignable<L, R> &&
multipliation_assignalbe<L, R> &&
division_assignable<L, R>;
template<class T>
concept unary_addable =
requires (T v) {
{ +v } -> std::same_as<T>;
};
template<class T>
concept unary_subtractable =
requires (T v) {
{ -v } -> std::same_as<T>;
};
template<class T>
concept numeric =
std::regular<T> &&
arithmetic_operable<T> &&
arithmetic_operation_assignable<T> &&
weakly_incrementable<T> &&
unary_addable<T> &&
unary_subtractable<T>;
} // namespace internal
} // namespace uni
|