llvm-project
584 строки · 27.2 Кб
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_LIMITS11#define _LIBCPP_LIMITS12
13/*
14limits synopsis
15
16namespace std
17{
18
19template<class T>
20class numeric_limits
21{
22public:
23static constexpr bool is_specialized = false;
24static constexpr T min() noexcept;
25static constexpr T max() noexcept;
26static constexpr T lowest() noexcept;
27
28static constexpr int digits = 0;
29static constexpr int digits10 = 0;
30static constexpr int max_digits10 = 0;
31static constexpr bool is_signed = false;
32static constexpr bool is_integer = false;
33static constexpr bool is_exact = false;
34static constexpr int radix = 0;
35static constexpr T epsilon() noexcept;
36static constexpr T round_error() noexcept;
37
38static constexpr int min_exponent = 0;
39static constexpr int min_exponent10 = 0;
40static constexpr int max_exponent = 0;
41static constexpr int max_exponent10 = 0;
42
43static constexpr bool has_infinity = false;
44static constexpr bool has_quiet_NaN = false;
45static constexpr bool has_signaling_NaN = false;
46static constexpr float_denorm_style has_denorm = denorm_absent; // deprecated in C++23
47static constexpr bool has_denorm_loss = false; // deprecated in C++23
48static constexpr T infinity() noexcept;
49static constexpr T quiet_NaN() noexcept;
50static constexpr T signaling_NaN() noexcept;
51static constexpr T denorm_min() noexcept;
52
53static constexpr bool is_iec559 = false;
54static constexpr bool is_bounded = false;
55static constexpr bool is_modulo = false;
56
57static constexpr bool traps = false;
58static constexpr bool tinyness_before = false;
59static constexpr float_round_style round_style = round_toward_zero;
60};
61
62enum float_round_style
63{
64round_indeterminate = -1,
65round_toward_zero = 0,
66round_to_nearest = 1,
67round_toward_infinity = 2,
68round_toward_neg_infinity = 3
69};
70
71enum float_denorm_style // deprecated in C++23
72{
73denorm_indeterminate = -1,
74denorm_absent = 0,
75denorm_present = 1
76};
77
78template<> class numeric_limits<cv bool>;
79
80template<> class numeric_limits<cv char>;
81template<> class numeric_limits<cv signed char>;
82template<> class numeric_limits<cv unsigned char>;
83template<> class numeric_limits<cv wchar_t>;
84template<> class numeric_limits<cv char8_t>; // C++20
85template<> class numeric_limits<cv char16_t>;
86template<> class numeric_limits<cv char32_t>;
87
88template<> class numeric_limits<cv short>;
89template<> class numeric_limits<cv int>;
90template<> class numeric_limits<cv long>;
91template<> class numeric_limits<cv long long>;
92template<> class numeric_limits<cv unsigned short>;
93template<> class numeric_limits<cv unsigned int>;
94template<> class numeric_limits<cv unsigned long>;
95template<> class numeric_limits<cv unsigned long long>;
96
97template<> class numeric_limits<cv float>;
98template<> class numeric_limits<cv double>;
99template<> class numeric_limits<cv long double>;
100
101} // std
102
103*/
104
105#include <__config>106#include <__type_traits/is_arithmetic.h>107#include <__type_traits/is_signed.h>108#include <__type_traits/remove_cv.h>109
110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)111# pragma GCC system_header112#endif113
114_LIBCPP_PUSH_MACROS
115#include <__undef_macros>116#include <version>117
118_LIBCPP_BEGIN_NAMESPACE_STD
119
120enum float_round_style {121round_indeterminate = -1,122round_toward_zero = 0,123round_to_nearest = 1,124round_toward_infinity = 2,125round_toward_neg_infinity = 3126};127
128enum _LIBCPP_DEPRECATED_IN_CXX23 float_denorm_style {129denorm_indeterminate = -1,130denorm_absent = 0,131denorm_present = 1132};133
134template <class _Tp, bool = is_arithmetic<_Tp>::value>135class __libcpp_numeric_limits {136protected:137typedef _Tp type;138
139static _LIBCPP_CONSTEXPR const bool is_specialized = false;140_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }141_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }142_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }143
144static _LIBCPP_CONSTEXPR const int digits = 0;145static _LIBCPP_CONSTEXPR const int digits10 = 0;146static _LIBCPP_CONSTEXPR const int max_digits10 = 0;147static _LIBCPP_CONSTEXPR const bool is_signed = false;148static _LIBCPP_CONSTEXPR const bool is_integer = false;149static _LIBCPP_CONSTEXPR const bool is_exact = false;150static _LIBCPP_CONSTEXPR const int radix = 0;151_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }152_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }153
154static _LIBCPP_CONSTEXPR const int min_exponent = 0;155static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;156static _LIBCPP_CONSTEXPR const int max_exponent = 0;157static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;158
159static _LIBCPP_CONSTEXPR const bool has_infinity = false;160static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;161static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;162static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;163static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;164_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }165_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }166_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }167_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }168
169static _LIBCPP_CONSTEXPR const bool is_iec559 = false;170static _LIBCPP_CONSTEXPR const bool is_bounded = false;171static _LIBCPP_CONSTEXPR const bool is_modulo = false;172
173static _LIBCPP_CONSTEXPR const bool traps = false;174static _LIBCPP_CONSTEXPR const bool tinyness_before = false;175static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;176};177
178template <class _Tp, int __digits, bool _IsSigned>179struct __libcpp_compute_min {180static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);181};182
183template <class _Tp, int __digits>184struct __libcpp_compute_min<_Tp, __digits, false> {185static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);186};187
188template <class _Tp>189class __libcpp_numeric_limits<_Tp, true> {190protected:191typedef _Tp type;192
193static _LIBCPP_CONSTEXPR const bool is_specialized = true;194
195static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);196static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);197static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;198static _LIBCPP_CONSTEXPR const int max_digits10 = 0;199static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;200static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);201_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }202_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }203_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }204
205static _LIBCPP_CONSTEXPR const bool is_integer = true;206static _LIBCPP_CONSTEXPR const bool is_exact = true;207static _LIBCPP_CONSTEXPR const int radix = 2;208_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }209_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }210
211static _LIBCPP_CONSTEXPR const int min_exponent = 0;212static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;213static _LIBCPP_CONSTEXPR const int max_exponent = 0;214static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;215
216static _LIBCPP_CONSTEXPR const bool has_infinity = false;217static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;218static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;219static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;220static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;221_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }222_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }223_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }224_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }225
226static _LIBCPP_CONSTEXPR const bool is_iec559 = false;227static _LIBCPP_CONSTEXPR const bool is_bounded = true;228static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;229
230#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)231static _LIBCPP_CONSTEXPR const bool traps = true;232#else233static _LIBCPP_CONSTEXPR const bool traps = false;234#endif235static _LIBCPP_CONSTEXPR const bool tinyness_before = false;236static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;237};238
239template <>240class __libcpp_numeric_limits<bool, true> {241protected:242typedef bool type;243
244static _LIBCPP_CONSTEXPR const bool is_specialized = true;245
246static _LIBCPP_CONSTEXPR const bool is_signed = false;247static _LIBCPP_CONSTEXPR const int digits = 1;248static _LIBCPP_CONSTEXPR const int digits10 = 0;249static _LIBCPP_CONSTEXPR const int max_digits10 = 0;250static _LIBCPP_CONSTEXPR const type __min = false;251static _LIBCPP_CONSTEXPR const type __max = true;252_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }253_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }254_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }255
256static _LIBCPP_CONSTEXPR const bool is_integer = true;257static _LIBCPP_CONSTEXPR const bool is_exact = true;258static _LIBCPP_CONSTEXPR const int radix = 2;259_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }260_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }261
262static _LIBCPP_CONSTEXPR const int min_exponent = 0;263static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;264static _LIBCPP_CONSTEXPR const int max_exponent = 0;265static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;266
267static _LIBCPP_CONSTEXPR const bool has_infinity = false;268static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;269static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;270static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;271static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;272_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }273_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }274_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }275_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }276
277static _LIBCPP_CONSTEXPR const bool is_iec559 = false;278static _LIBCPP_CONSTEXPR const bool is_bounded = true;279static _LIBCPP_CONSTEXPR const bool is_modulo = false;280
281static _LIBCPP_CONSTEXPR const bool traps = false;282static _LIBCPP_CONSTEXPR const bool tinyness_before = false;283static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;284};285
286template <>287class __libcpp_numeric_limits<float, true> {288protected:289typedef float type;290
291static _LIBCPP_CONSTEXPR const bool is_specialized = true;292
293static _LIBCPP_CONSTEXPR const bool is_signed = true;294static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;295static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;296static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;297_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }298_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }299_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }300
301static _LIBCPP_CONSTEXPR const bool is_integer = false;302static _LIBCPP_CONSTEXPR const bool is_exact = false;303static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;304_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }305_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }306
307static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;308static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;309static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;310static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;311
312static _LIBCPP_CONSTEXPR const bool has_infinity = true;313static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;314static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;315static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;316static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;317_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {318return __builtin_huge_valf();319}320_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {321return __builtin_nanf("");322}323_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {324return __builtin_nansf("");325}326_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {327return __FLT_DENORM_MIN__;328}329
330static _LIBCPP_CONSTEXPR const bool is_iec559 = true;331static _LIBCPP_CONSTEXPR const bool is_bounded = true;332static _LIBCPP_CONSTEXPR const bool is_modulo = false;333
334static _LIBCPP_CONSTEXPR const bool traps = false;335#if (defined(__arm__) || defined(__aarch64__))336static _LIBCPP_CONSTEXPR const bool tinyness_before = true;337#else338static _LIBCPP_CONSTEXPR const bool tinyness_before = false;339#endif340static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;341};342
343template <>344class __libcpp_numeric_limits<double, true> {345protected:346typedef double type;347
348static _LIBCPP_CONSTEXPR const bool is_specialized = true;349
350static _LIBCPP_CONSTEXPR const bool is_signed = true;351static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;352static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;353static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;354_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }355_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }356_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }357
358static _LIBCPP_CONSTEXPR const bool is_integer = false;359static _LIBCPP_CONSTEXPR const bool is_exact = false;360static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;361_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }362_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }363
364static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;365static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;366static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;367static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;368
369static _LIBCPP_CONSTEXPR const bool has_infinity = true;370static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;371static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;372static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;373static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;374_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {375return __builtin_huge_val();376}377_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {378return __builtin_nan("");379}380_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {381return __builtin_nans("");382}383_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {384return __DBL_DENORM_MIN__;385}386
387static _LIBCPP_CONSTEXPR const bool is_iec559 = true;388static _LIBCPP_CONSTEXPR const bool is_bounded = true;389static _LIBCPP_CONSTEXPR const bool is_modulo = false;390
391static _LIBCPP_CONSTEXPR const bool traps = false;392#if (defined(__arm__) || defined(__aarch64__))393static _LIBCPP_CONSTEXPR const bool tinyness_before = true;394#else395static _LIBCPP_CONSTEXPR const bool tinyness_before = false;396#endif397static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;398};399
400template <>401class __libcpp_numeric_limits<long double, true> {402protected:403typedef long double type;404
405static _LIBCPP_CONSTEXPR const bool is_specialized = true;406
407static _LIBCPP_CONSTEXPR const bool is_signed = true;408static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;409static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;410static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;411_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }412_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }413_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }414
415static _LIBCPP_CONSTEXPR const bool is_integer = false;416static _LIBCPP_CONSTEXPR const bool is_exact = false;417static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;418_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }419_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }420
421static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;422static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;423static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;424static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;425
426static _LIBCPP_CONSTEXPR const bool has_infinity = true;427static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;428static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;429static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;430static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;431_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {432return __builtin_huge_vall();433}434_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {435return __builtin_nanl("");436}437_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {438return __builtin_nansl("");439}440_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {441return __LDBL_DENORM_MIN__;442}443
444#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)445static _LIBCPP_CONSTEXPR const bool is_iec559 = false;446#else447static _LIBCPP_CONSTEXPR const bool is_iec559 = true;448#endif449static _LIBCPP_CONSTEXPR const bool is_bounded = true;450static _LIBCPP_CONSTEXPR const bool is_modulo = false;451
452static _LIBCPP_CONSTEXPR const bool traps = false;453#if (defined(__arm__) || defined(__aarch64__))454static _LIBCPP_CONSTEXPR const bool tinyness_before = true;455#else456static _LIBCPP_CONSTEXPR const bool tinyness_before = false;457#endif458static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;459};460
461template <class _Tp>462class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> {463typedef __libcpp_numeric_limits<_Tp> __base;464typedef typename __base::type type;465
466public:467static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;468_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }469_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }470_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }471
472static _LIBCPP_CONSTEXPR const int digits = __base::digits;473static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;474static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;475static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;476static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;477static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;478static _LIBCPP_CONSTEXPR const int radix = __base::radix;479_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {480return __base::epsilon();481}482_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {483return __base::round_error();484}485
486static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;487static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;488static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;489static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;490
491static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;492static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;493static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;494_LIBCPP_SUPPRESS_DEPRECATED_PUSH
495static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;496static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;497_LIBCPP_SUPPRESS_DEPRECATED_POP
498_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {499return __base::infinity();500}501_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {502return __base::quiet_NaN();503}504_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {505return __base::signaling_NaN();506}507_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {508return __base::denorm_min();509}510
511static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;512static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;513static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;514
515static _LIBCPP_CONSTEXPR const bool traps = __base::traps;516static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;517static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;518};519
520template <class _Tp>521_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;522template <class _Tp>523_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;524template <class _Tp>525_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;526template <class _Tp>527_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;528template <class _Tp>529_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;530template <class _Tp>531_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;532template <class _Tp>533_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;534template <class _Tp>535_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;536template <class _Tp>537_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;538template <class _Tp>539_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;540template <class _Tp>541_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;542template <class _Tp>543_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;544template <class _Tp>545_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;546template <class _Tp>547_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;548template <class _Tp>549_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;550template <class _Tp>551_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;552template <class _Tp>553_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;554template <class _Tp>555_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;556template <class _Tp>557_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;558template <class _Tp>559_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;560template <class _Tp>561_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;562template <class _Tp>563_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;564template <class _Tp>565_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;566
567template <class _Tp>568class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};569
570template <class _Tp>571class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};572
573template <class _Tp>574class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};575
576_LIBCPP_END_NAMESPACE_STD
577
578_LIBCPP_POP_MACROS
579
580#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20581# include <type_traits>582#endif583
584#endif // _LIBCPP_LIMITS585