29template <
template <
typename>
class _Trait,
typename _Tp,
typename =
void>
32template <
template <
typename>
class _Trait,
typename _Tp>
33 struct __value_exists_impl<_Trait, _Tp,
void_t<decltype(_Trait<_Tp>::value)>>
36template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
37 struct __digits_impl {};
39template <
typename _Tp>
40 struct __digits_impl<_Tp, true>
42 static inline constexpr int value
43 =
sizeof(_Tp) * __CHAR_BIT__ - is_signed_v<_Tp>;
47 struct __digits_impl<float, true>
48 {
static inline constexpr int value = __FLT_MANT_DIG__; };
51 struct __digits_impl<double, true>
52 {
static inline constexpr int value = __DBL_MANT_DIG__; };
55 struct __digits_impl<long double, true>
56 {
static inline constexpr int value = __LDBL_MANT_DIG__; };
58template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
59 struct __digits10_impl {};
61template <
typename _Tp>
62 struct __digits10_impl<_Tp, true>
65 static inline constexpr int value = __digits_impl<_Tp>::value * 643L / 2136;
69 struct __digits10_impl<float, true>
70 {
static inline constexpr int value = __FLT_DIG__; };
73 struct __digits10_impl<double, true>
74 {
static inline constexpr int value = __DBL_DIG__; };
77 struct __digits10_impl<long double, true>
78 {
static inline constexpr int value = __LDBL_DIG__; };
80template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
81 struct __max_digits10_impl {};
83template <
typename _Tp>
84 struct __max_digits10_impl<_Tp, true>
86 static inline constexpr int value
87 = is_floating_point_v<_Tp> ? 2 + __digits_impl<_Tp>::value * 643L / 2136
88 : __digits10_impl<_Tp>::value + 1;
91template <
typename _Tp>
92 struct __max_exponent_impl {};
95 struct __max_exponent_impl<float>
96 {
static inline constexpr int value = __FLT_MAX_EXP__; };
99 struct __max_exponent_impl<double>
100 {
static inline constexpr int value = __DBL_MAX_EXP__; };
103 struct __max_exponent_impl<long double>
104 {
static inline constexpr int value = __LDBL_MAX_EXP__; };
106template <
typename _Tp>
107 struct __max_exponent10_impl {};
110 struct __max_exponent10_impl<float>
111 {
static inline constexpr int value = __FLT_MAX_10_EXP__; };
114 struct __max_exponent10_impl<double>
115 {
static inline constexpr int value = __DBL_MAX_10_EXP__; };
118 struct __max_exponent10_impl<long double>
119 {
static inline constexpr int value = __LDBL_MAX_10_EXP__; };
121template <
typename _Tp>
122 struct __min_exponent_impl {};
125 struct __min_exponent_impl<float>
126 {
static inline constexpr int value = __FLT_MIN_EXP__; };
129 struct __min_exponent_impl<double>
130 {
static inline constexpr int value = __DBL_MIN_EXP__; };
133 struct __min_exponent_impl<long double>
134 {
static inline constexpr int value = __LDBL_MIN_EXP__; };
136template <
typename _Tp>
137 struct __min_exponent10_impl {};
140 struct __min_exponent10_impl<float>
141 {
static inline constexpr int value = __FLT_MIN_10_EXP__; };
144 struct __min_exponent10_impl<double>
145 {
static inline constexpr int value = __DBL_MIN_10_EXP__; };
148 struct __min_exponent10_impl<long double>
149 {
static inline constexpr int value = __LDBL_MIN_10_EXP__; };
151template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
152 struct __radix_impl {};
154template <
typename _Tp>
155 struct __radix_impl<_Tp, true>
157 static inline constexpr int value
158 = is_floating_point_v<_Tp> ? __FLT_RADIX__ : 2;
162template <
template <
typename>
class _Trait,
typename _Tp>
163 struct __value_exists : __value_exists_impl<_Trait, _Tp> {};
165template <
template <
typename>
class _Trait,
typename _Tp>
166 inline constexpr bool __value_exists_v = __value_exists<_Trait, _Tp>::value;
168template <
template <
typename>
class _Trait,
typename _Tp,
typename _Up = _Tp>
170 __value_or(_Up __def = _Up()) noexcept
172 if constexpr (__value_exists_v<_Trait, _Tp>)
173 return static_cast<_Up
>(_Trait<_Tp>::value);
178template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
179 struct __norm_min_impl {};
181template <
typename _Tp>
182 struct __norm_min_impl<_Tp, true>
183 {
static inline constexpr _Tp value = 1; };
186 struct __norm_min_impl<float, true>
187 {
static inline constexpr float value = __FLT_MIN__; };
190 struct __norm_min_impl<double, true>
191 {
static inline constexpr double value = __DBL_MIN__; };
194 struct __norm_min_impl<long double, true>
195 {
static inline constexpr long double value = __LDBL_MIN__; };
197template <
typename _Tp>
198 struct __denorm_min_impl : __norm_min_impl<_Tp> {};
200#if __FLT_HAS_DENORM__
202 struct __denorm_min_impl<float>
203 {
static inline constexpr float value = __FLT_DENORM_MIN__; };
206#if __DBL_HAS_DENORM__
208 struct __denorm_min_impl<double>
209 {
static inline constexpr double value = __DBL_DENORM_MIN__; };
212#if __LDBL_HAS_DENORM__
214 struct __denorm_min_impl<long double>
215 {
static inline constexpr long double value = __LDBL_DENORM_MIN__; };
218template <
typename _Tp>
219 struct __epsilon_impl {};
222 struct __epsilon_impl<float>
223 {
static inline constexpr float value = __FLT_EPSILON__; };
226 struct __epsilon_impl<double>
227 {
static inline constexpr double value = __DBL_EPSILON__; };
230 struct __epsilon_impl<long double>
231 {
static inline constexpr long double value = __LDBL_EPSILON__; };
233template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
234 struct __finite_min_impl {};
236template <
typename _Tp>
237 struct __finite_min_impl<_Tp, true>
239 static inline constexpr _Tp value
240 = is_unsigned_v<_Tp> ? _Tp()
241 : -2 * (_Tp(1) << __digits_impl<_Tp>::value - 1);
245 struct __finite_min_impl<float, true>
246 {
static inline constexpr float value = -__FLT_MAX__; };
249 struct __finite_min_impl<double, true>
250 {
static inline constexpr double value = -__DBL_MAX__; };
253 struct __finite_min_impl<long double, true>
254 {
static inline constexpr long double value = -__LDBL_MAX__; };
256template <
typename _Tp,
bool = is_arithmetic_v<_Tp>>
257 struct __finite_max_impl {};
259template <
typename _Tp>
260 struct __finite_max_impl<_Tp, true>
261 {
static inline constexpr _Tp value = ~__finite_min_impl<_Tp>::value; };
264 struct __finite_max_impl<float, true>
265 {
static inline constexpr float value = __FLT_MAX__; };
268 struct __finite_max_impl<double, true>
269 {
static inline constexpr double value = __DBL_MAX__; };
272 struct __finite_max_impl<long double, true>
273 {
static inline constexpr long double value = __LDBL_MAX__; };
275template <
typename _Tp>
276 struct __infinity_impl {};
278#if __FLT_HAS_INFINITY__
280 struct __infinity_impl<float>
281 {
static inline constexpr float value = __builtin_inff(); };
284#if __DBL_HAS_INFINITY__
286 struct __infinity_impl<double>
287 {
static inline constexpr double value = __builtin_inf(); };
290#if __LDBL_HAS_INFINITY__
292 struct __infinity_impl<long double>
293 {
static inline constexpr long double value = __builtin_infl(); };
296template <
typename _Tp>
297 struct __quiet_NaN_impl {};
299#if __FLT_HAS_QUIET_NAN__
301 struct __quiet_NaN_impl<float>
302 {
static inline constexpr float value = __builtin_nanf(
""); };
305#if __DBL_HAS_QUIET_NAN__
307 struct __quiet_NaN_impl<double>
308 {
static inline constexpr double value = __builtin_nan(
""); };
311#if __LDBL_HAS_QUIET_NAN__
313 struct __quiet_NaN_impl<long double>
314 {
static inline constexpr long double value = __builtin_nanl(
""); };
317template <
typename _Tp,
bool = is_
floating_po
int_v<_Tp>>
318 struct __reciprocal_overflow_threshold_impl {};
320template <
typename _Tp>
321 struct __reciprocal_overflow_threshold_impl<_Tp, true>
325 static constexpr _Tp _S_search(_Tp __ok, _Tp __overflows)
327 const _Tp __mid = (__ok + __overflows) / 2;
332 if (__mid == __ok || __mid == __overflows)
334 else if (_Tp(1) / (__radix_impl<_Tp>::value * __mid)
335 <= __finite_max_impl<_Tp>::value / __radix_impl<_Tp>::value)
336 return _S_search(__mid, __overflows);
338 return _S_search(__ok, __mid);
341 static inline constexpr _Tp value
342 = _S_search(_Tp(1.01) / __finite_max_impl<_Tp>::value,
343 _Tp(0.99) / __finite_max_impl<_Tp>::value);
346template <
typename _Tp,
bool = is_
floating_po
int_v<_Tp>>
347 struct __round_error_impl {};
349template <
typename _Tp>
350 struct __round_error_impl<_Tp, true>
351 {
static inline constexpr _Tp value = 0.5; };
353template <
typename _Tp>
354 struct __signaling_NaN_impl {};
356#if __FLT_HAS_QUIET_NAN__
358 struct __signaling_NaN_impl<float>
359 {
static inline constexpr float value = __builtin_nansf(
""); };
362#if __DBL_HAS_QUIET_NAN__
364 struct __signaling_NaN_impl<double>
365 {
static inline constexpr double value = __builtin_nans(
""); };
368#if __LDBL_HAS_QUIET_NAN__
370 struct __signaling_NaN_impl<long double>
371 {
static inline constexpr long double value = __builtin_nansl(
""); };
375template <
typename _Tp>
376 struct __denorm_min : __denorm_min_impl<remove_cv_t<_Tp>> {};
378template <
typename _Tp>
379 struct __epsilon : __epsilon_impl<remove_cv_t<_Tp>> {};
381template <
typename _Tp>
382 struct __finite_max : __finite_max_impl<remove_cv_t<_Tp>> {};
384template <
typename _Tp>
385 struct __finite_min : __finite_min_impl<remove_cv_t<_Tp>> {};
387template <
typename _Tp>
388 struct __infinity : __infinity_impl<remove_cv_t<_Tp>> {};
390template <
typename _Tp>
391 struct __norm_min : __norm_min_impl<remove_cv_t<_Tp>> {};
393template <
typename _Tp>
394 struct __quiet_NaN : __quiet_NaN_impl<remove_cv_t<_Tp>> {};
396template <
typename _Tp>
397 struct __reciprocal_overflow_threshold
398 : __reciprocal_overflow_threshold_impl<remove_cv_t<_Tp>> {};
400template <
typename _Tp>
401 struct __round_error : __round_error_impl<remove_cv_t<_Tp>> {};
403template <
typename _Tp>
404 struct __signaling_NaN : __signaling_NaN_impl<remove_cv_t<_Tp>> {};
406template <
typename _Tp>
407 inline constexpr auto __denorm_min_v = __denorm_min<_Tp>::value;
409template <
typename _Tp>
410 inline constexpr auto __epsilon_v = __epsilon<_Tp>::value;
412template <
typename _Tp>
413 inline constexpr auto __finite_max_v = __finite_max<_Tp>::value;
415template <
typename _Tp>
416 inline constexpr auto __finite_min_v = __finite_min<_Tp>::value;
418template <
typename _Tp>
419 inline constexpr auto __infinity_v = __infinity<_Tp>::value;
421template <
typename _Tp>
422 inline constexpr auto __norm_min_v = __norm_min<_Tp>::value;
424template <
typename _Tp>
425 inline constexpr auto __quiet_NaN_v = __quiet_NaN<_Tp>::value;
427template <
typename _Tp>
428 inline constexpr auto __reciprocal_overflow_threshold_v
429 = __reciprocal_overflow_threshold<_Tp>::value;
431template <
typename _Tp>
432 inline constexpr auto __round_error_v = __round_error<_Tp>::value;
434template <
typename _Tp>
435 inline constexpr auto __signaling_NaN_v = __signaling_NaN<_Tp>::value;
438template <
typename _Tp>
439 struct __digits : __digits_impl<remove_cv_t<_Tp>> {};
441template <
typename _Tp>
442 struct __digits10 : __digits10_impl<remove_cv_t<_Tp>> {};
444template <
typename _Tp>
445 struct __max_digits10 : __max_digits10_impl<remove_cv_t<_Tp>> {};
447template <
typename _Tp>
448 struct __max_exponent : __max_exponent_impl<remove_cv_t<_Tp>> {};
450template <
typename _Tp>
451 struct __max_exponent10 : __max_exponent10_impl<remove_cv_t<_Tp>> {};
453template <
typename _Tp>
454 struct __min_exponent : __min_exponent_impl<remove_cv_t<_Tp>> {};
456template <
typename _Tp>
457 struct __min_exponent10 : __min_exponent10_impl<remove_cv_t<_Tp>> {};
459template <
typename _Tp>
460 struct __radix : __radix_impl<remove_cv_t<_Tp>> {};
462template <
typename _Tp>
463 inline constexpr auto __digits_v = __digits<_Tp>::value;
465template <
typename _Tp>
466 inline constexpr auto __digits10_v = __digits10<_Tp>::value;
468template <
typename _Tp>
469 inline constexpr auto __max_digits10_v = __max_digits10<_Tp>::value;
471template <
typename _Tp>
472 inline constexpr auto __max_exponent_v = __max_exponent<_Tp>::value;
474template <
typename _Tp>
475 inline constexpr auto __max_exponent10_v = __max_exponent10<_Tp>::value;
477template <
typename _Tp>
478 inline constexpr auto __min_exponent_v = __min_exponent<_Tp>::value;
480template <
typename _Tp>
481 inline constexpr auto __min_exponent10_v = __min_exponent10<_Tp>::value;
483template <
typename _Tp>
484 inline constexpr auto __radix_v = __radix<_Tp>::value;
488template <
typename _Tp>
489 struct __has_iec559_storage_format :
true_type {};
491template <
typename _Tp>
492 inline constexpr bool __has_iec559_storage_format_v
493 = __has_iec559_storage_format<_Tp>::value;
510template <
template <
typename>
class _Trait,
typename _Tp>
513template <
template <
typename>
class _Trait,
typename _Tp>
514 inline constexpr bool __has_iec559_behavior_v
515 = __has_iec559_behavior<_Trait, _Tp>::value;
517#if !__FINITE_MATH_ONLY__
518#if __FLT_HAS_QUIET_NAN__
520 struct __has_iec559_behavior<__quiet_NaN, float> :
true_type {};
523#if __DBL_HAS_QUIET_NAN__
525 struct __has_iec559_behavior<__quiet_NaN, double> :
true_type {};
528#if __LDBL_HAS_QUIET_NAN__
530 struct __has_iec559_behavior<__quiet_NaN, long double> :
true_type {};
533#if __FLT_HAS_INFINITY__
535 struct __has_iec559_behavior<__infinity, float> :
true_type {};
538#if __DBL_HAS_INFINITY__
540 struct __has_iec559_behavior<__infinity, double> :
true_type {};
543#if __LDBL_HAS_INFINITY__
545 struct __has_iec559_behavior<__infinity, long double> :
true_type {};
548#ifdef __SUPPORT_SNAN__
549#if __FLT_HAS_QUIET_NAN__
551 struct __has_iec559_behavior<__signaling_NaN, float> :
true_type {};
554#if __DBL_HAS_QUIET_NAN__
556 struct __has_iec559_behavior<__signaling_NaN, double> :
true_type {};
559#if __LDBL_HAS_QUIET_NAN__
561 struct __has_iec559_behavior<__signaling_NaN, long double> :
true_type {};
void void_t
A metafunction that always yields void, used for detecting valid types.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
ISO C++ entities toplevel namespace is std.