Warning, /include/c++/v1/__cxx03/limits is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP___CXX03_LIMITS
0011 #define _LIBCPP___CXX03_LIMITS
0012
0013 /*
0014 limits synopsis
0015
0016 namespace std
0017 {
0018
0019 template<class T>
0020 class numeric_limits
0021 {
0022 public:
0023 static constexpr bool is_specialized = false;
0024 static constexpr T min() noexcept;
0025 static constexpr T max() noexcept;
0026 static constexpr T lowest() noexcept;
0027
0028 static constexpr int digits = 0;
0029 static constexpr int digits10 = 0;
0030 static constexpr int max_digits10 = 0;
0031 static constexpr bool is_signed = false;
0032 static constexpr bool is_integer = false;
0033 static constexpr bool is_exact = false;
0034 static constexpr int radix = 0;
0035 static constexpr T epsilon() noexcept;
0036 static constexpr T round_error() noexcept;
0037
0038 static constexpr int min_exponent = 0;
0039 static constexpr int min_exponent10 = 0;
0040 static constexpr int max_exponent = 0;
0041 static constexpr int max_exponent10 = 0;
0042
0043 static constexpr bool has_infinity = false;
0044 static constexpr bool has_quiet_NaN = false;
0045 static constexpr bool has_signaling_NaN = false;
0046 static constexpr float_denorm_style has_denorm = denorm_absent; // deprecated in C++23
0047 static constexpr bool has_denorm_loss = false; // deprecated in C++23
0048 static constexpr T infinity() noexcept;
0049 static constexpr T quiet_NaN() noexcept;
0050 static constexpr T signaling_NaN() noexcept;
0051 static constexpr T denorm_min() noexcept;
0052
0053 static constexpr bool is_iec559 = false;
0054 static constexpr bool is_bounded = false;
0055 static constexpr bool is_modulo = false;
0056
0057 static constexpr bool traps = false;
0058 static constexpr bool tinyness_before = false;
0059 static constexpr float_round_style round_style = round_toward_zero;
0060 };
0061
0062 enum float_round_style
0063 {
0064 round_indeterminate = -1,
0065 round_toward_zero = 0,
0066 round_to_nearest = 1,
0067 round_toward_infinity = 2,
0068 round_toward_neg_infinity = 3
0069 };
0070
0071 enum float_denorm_style // deprecated in C++23
0072 {
0073 denorm_indeterminate = -1,
0074 denorm_absent = 0,
0075 denorm_present = 1
0076 };
0077
0078 template<> class numeric_limits<cv bool>;
0079
0080 template<> class numeric_limits<cv char>;
0081 template<> class numeric_limits<cv signed char>;
0082 template<> class numeric_limits<cv unsigned char>;
0083 template<> class numeric_limits<cv wchar_t>;
0084 template<> class numeric_limits<cv char8_t>; // C++20
0085 template<> class numeric_limits<cv char16_t>;
0086 template<> class numeric_limits<cv char32_t>;
0087
0088 template<> class numeric_limits<cv short>;
0089 template<> class numeric_limits<cv int>;
0090 template<> class numeric_limits<cv long>;
0091 template<> class numeric_limits<cv long long>;
0092 template<> class numeric_limits<cv unsigned short>;
0093 template<> class numeric_limits<cv unsigned int>;
0094 template<> class numeric_limits<cv unsigned long>;
0095 template<> class numeric_limits<cv unsigned long long>;
0096
0097 template<> class numeric_limits<cv float>;
0098 template<> class numeric_limits<cv double>;
0099 template<> class numeric_limits<cv long double>;
0100
0101 } // std
0102
0103 */
0104
0105 #include <__cxx03/__config>
0106 #include <__cxx03/__type_traits/is_arithmetic.h>
0107 #include <__cxx03/__type_traits/is_signed.h>
0108 #include <__cxx03/__type_traits/remove_cv.h>
0109
0110 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0111 # pragma GCC system_header
0112 #endif
0113
0114 _LIBCPP_PUSH_MACROS
0115 #include <__cxx03/__undef_macros>
0116 #include <__cxx03/version>
0117
0118 _LIBCPP_BEGIN_NAMESPACE_STD
0119
0120 enum float_round_style {
0121 round_indeterminate = -1,
0122 round_toward_zero = 0,
0123 round_to_nearest = 1,
0124 round_toward_infinity = 2,
0125 round_toward_neg_infinity = 3
0126 };
0127
0128 enum _LIBCPP_DEPRECATED_IN_CXX23 float_denorm_style {
0129 denorm_indeterminate = -1,
0130 denorm_absent = 0,
0131 denorm_present = 1
0132 };
0133
0134 template <class _Tp, bool = is_arithmetic<_Tp>::value>
0135 class __libcpp_numeric_limits {
0136 protected:
0137 typedef _Tp type;
0138
0139 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
0140 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }
0141 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }
0142 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }
0143
0144 static _LIBCPP_CONSTEXPR const int digits = 0;
0145 static _LIBCPP_CONSTEXPR const int digits10 = 0;
0146 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
0147 static _LIBCPP_CONSTEXPR const bool is_signed = false;
0148 static _LIBCPP_CONSTEXPR const bool is_integer = false;
0149 static _LIBCPP_CONSTEXPR const bool is_exact = false;
0150 static _LIBCPP_CONSTEXPR const int radix = 0;
0151 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }
0152 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }
0153
0154 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
0155 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
0156 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
0157 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
0158
0159 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
0160 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
0161 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
0162 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
0163 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0164 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }
0165 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }
0166 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }
0167 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }
0168
0169 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
0170 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
0171 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
0172
0173 static _LIBCPP_CONSTEXPR const bool traps = false;
0174 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0175 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
0176 };
0177
0178 template <class _Tp, int __digits, bool _IsSigned>
0179 struct __libcpp_compute_min {
0180 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);
0181 };
0182
0183 template <class _Tp, int __digits>
0184 struct __libcpp_compute_min<_Tp, __digits, false> {
0185 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
0186 };
0187
0188 template <class _Tp>
0189 class __libcpp_numeric_limits<_Tp, true> {
0190 protected:
0191 typedef _Tp type;
0192
0193 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
0194
0195 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
0196 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
0197 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
0198 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
0199 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
0200 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
0201 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
0202 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
0203 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
0204
0205 static _LIBCPP_CONSTEXPR const bool is_integer = true;
0206 static _LIBCPP_CONSTEXPR const bool is_exact = true;
0207 static _LIBCPP_CONSTEXPR const int radix = 2;
0208 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
0209 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
0210
0211 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
0212 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
0213 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
0214 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
0215
0216 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
0217 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
0218 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
0219 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
0220 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0221 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
0222 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
0223 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
0224 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
0225
0226 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
0227 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
0228 static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;
0229
0230 #if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)
0231 static _LIBCPP_CONSTEXPR const bool traps = true;
0232 #else
0233 static _LIBCPP_CONSTEXPR const bool traps = false;
0234 #endif
0235 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0236 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
0237 };
0238
0239 template <>
0240 class __libcpp_numeric_limits<bool, true> {
0241 protected:
0242 typedef bool type;
0243
0244 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
0245
0246 static _LIBCPP_CONSTEXPR const bool is_signed = false;
0247 static _LIBCPP_CONSTEXPR const int digits = 1;
0248 static _LIBCPP_CONSTEXPR const int digits10 = 0;
0249 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
0250 static _LIBCPP_CONSTEXPR const type __min = false;
0251 static _LIBCPP_CONSTEXPR const type __max = true;
0252 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
0253 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
0254 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
0255
0256 static _LIBCPP_CONSTEXPR const bool is_integer = true;
0257 static _LIBCPP_CONSTEXPR const bool is_exact = true;
0258 static _LIBCPP_CONSTEXPR const int radix = 2;
0259 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
0260 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
0261
0262 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
0263 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
0264 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
0265 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
0266
0267 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
0268 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
0269 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
0270 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
0271 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0272 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
0273 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
0274 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
0275 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
0276
0277 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
0278 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
0279 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
0280
0281 static _LIBCPP_CONSTEXPR const bool traps = false;
0282 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0283 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
0284 };
0285
0286 template <>
0287 class __libcpp_numeric_limits<float, true> {
0288 protected:
0289 typedef float type;
0290
0291 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
0292
0293 static _LIBCPP_CONSTEXPR const bool is_signed = true;
0294 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
0295 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
0296 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
0297 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }
0298 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }
0299 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
0300
0301 static _LIBCPP_CONSTEXPR const bool is_integer = false;
0302 static _LIBCPP_CONSTEXPR const bool is_exact = false;
0303 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
0304 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }
0305 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }
0306
0307 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
0308 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
0309 static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;
0310 static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;
0311
0312 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
0313 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
0314 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
0315 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
0316 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0317 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
0318 return __builtin_huge_valf();
0319 }
0320 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
0321 return __builtin_nanf("");
0322 }
0323 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
0324 return __builtin_nansf("");
0325 }
0326 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
0327 return __FLT_DENORM_MIN__;
0328 }
0329
0330 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
0331 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
0332 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
0333
0334 static _LIBCPP_CONSTEXPR const bool traps = false;
0335 #if (defined(__arm__) || defined(__aarch64__))
0336 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
0337 #else
0338 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0339 #endif
0340 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
0341 };
0342
0343 template <>
0344 class __libcpp_numeric_limits<double, true> {
0345 protected:
0346 typedef double type;
0347
0348 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
0349
0350 static _LIBCPP_CONSTEXPR const bool is_signed = true;
0351 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
0352 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
0353 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
0354 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }
0355 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }
0356 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
0357
0358 static _LIBCPP_CONSTEXPR const bool is_integer = false;
0359 static _LIBCPP_CONSTEXPR const bool is_exact = false;
0360 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
0361 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }
0362 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }
0363
0364 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
0365 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
0366 static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;
0367 static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;
0368
0369 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
0370 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
0371 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
0372 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
0373 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0374 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
0375 return __builtin_huge_val();
0376 }
0377 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
0378 return __builtin_nan("");
0379 }
0380 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
0381 return __builtin_nans("");
0382 }
0383 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
0384 return __DBL_DENORM_MIN__;
0385 }
0386
0387 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
0388 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
0389 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
0390
0391 static _LIBCPP_CONSTEXPR const bool traps = false;
0392 #if (defined(__arm__) || defined(__aarch64__))
0393 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
0394 #else
0395 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0396 #endif
0397 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
0398 };
0399
0400 template <>
0401 class __libcpp_numeric_limits<long double, true> {
0402 protected:
0403 typedef long double type;
0404
0405 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
0406
0407 static _LIBCPP_CONSTEXPR const bool is_signed = true;
0408 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
0409 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
0410 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
0411 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }
0412 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }
0413 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
0414
0415 static _LIBCPP_CONSTEXPR const bool is_integer = false;
0416 static _LIBCPP_CONSTEXPR const bool is_exact = false;
0417 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
0418 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }
0419 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }
0420
0421 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
0422 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
0423 static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;
0424 static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;
0425
0426 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
0427 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
0428 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
0429 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
0430 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
0431 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
0432 return __builtin_huge_vall();
0433 }
0434 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
0435 return __builtin_nanl("");
0436 }
0437 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
0438 return __builtin_nansl("");
0439 }
0440 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
0441 return __LDBL_DENORM_MIN__;
0442 }
0443
0444 #if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
0445 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
0446 #else
0447 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
0448 #endif
0449 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
0450 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
0451
0452 static _LIBCPP_CONSTEXPR const bool traps = false;
0453 #if (defined(__arm__) || defined(__aarch64__))
0454 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
0455 #else
0456 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
0457 #endif
0458 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
0459 };
0460
0461 template <class _Tp>
0462 class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> {
0463 typedef __libcpp_numeric_limits<_Tp> __base;
0464 typedef typename __base::type type;
0465
0466 public:
0467 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
0468 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
0469 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
0470 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
0471
0472 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
0473 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
0474 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
0475 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
0476 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
0477 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
0478 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
0479 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
0480 return __base::epsilon();
0481 }
0482 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
0483 return __base::round_error();
0484 }
0485
0486 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
0487 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
0488 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
0489 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
0490
0491 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
0492 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
0493 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
0494 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
0495 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
0496 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
0497 _LIBCPP_SUPPRESS_DEPRECATED_POP
0498 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
0499 return __base::infinity();
0500 }
0501 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
0502 return __base::quiet_NaN();
0503 }
0504 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
0505 return __base::signaling_NaN();
0506 }
0507 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
0508 return __base::denorm_min();
0509 }
0510
0511 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
0512 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
0513 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
0514
0515 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
0516 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
0517 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
0518 };
0519
0520 template <class _Tp>
0521 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
0522 template <class _Tp>
0523 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
0524 template <class _Tp>
0525 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
0526 template <class _Tp>
0527 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
0528 template <class _Tp>
0529 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
0530 template <class _Tp>
0531 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
0532 template <class _Tp>
0533 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
0534 template <class _Tp>
0535 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
0536 template <class _Tp>
0537 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
0538 template <class _Tp>
0539 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
0540 template <class _Tp>
0541 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
0542 template <class _Tp>
0543 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
0544 template <class _Tp>
0545 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
0546 template <class _Tp>
0547 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
0548 template <class _Tp>
0549 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
0550 template <class _Tp>
0551 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
0552 template <class _Tp>
0553 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
0554 template <class _Tp>
0555 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
0556 template <class _Tp>
0557 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
0558 template <class _Tp>
0559 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
0560 template <class _Tp>
0561 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
0562 template <class _Tp>
0563 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
0564 template <class _Tp>
0565 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
0566
0567 template <class _Tp>
0568 class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
0569
0570 template <class _Tp>
0571 class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};
0572
0573 template <class _Tp>
0574 class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};
0575
0576 _LIBCPP_END_NAMESPACE_STD
0577
0578 _LIBCPP_POP_MACROS
0579
0580 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0581 # include <__cxx03/type_traits>
0582 #endif
0583
0584 #endif // _LIBCPP___CXX03_LIMITS