[numeric.limits.general] (original) (raw)

17 Language support library [support]

17.3 Implementation properties [support.limits]

17.3.5 Class template numeric_limits [numeric.limits]

17.3.5.1 General [numeric.limits.general]

Thenumeric_limitsclass template provides a C++ program with information about various properties of the implementation's representation of the arithmetic types.

namespace std { template<class T> class numeric_limits { public: static constexpr bool is_specialized = false;static constexpr T min() noexcept { return T(); } static constexpr T max() noexcept { return T(); } static constexpr T lowest() noexcept { return T(); } static constexpr int digits = 0;static constexpr int digits10 = 0;static constexpr int max_digits10 = 0;static constexpr bool is_signed = false;static constexpr bool is_integer = false;static constexpr bool is_exact = false;static constexpr int radix = 0;static constexpr T epsilon() noexcept { return T(); } static constexpr T round_error() noexcept { return T(); } static constexpr int min_exponent = 0;static constexpr int min_exponent10 = 0;static constexpr int max_exponent = 0;static constexpr int max_exponent10 = 0;static constexpr bool has_infinity = false;static constexpr bool has_quiet_NaN = false;static constexpr bool has_signaling_NaN = false;static constexpr T infinity() noexcept { return T(); } static constexpr T quiet_NaN() noexcept { return T(); } static constexpr T signaling_NaN() noexcept { return T(); } static constexpr T denorm_min() noexcept { return T(); } static constexpr bool is_iec559 = false;static constexpr bool is_bounded = false;static constexpr bool is_modulo = false;static constexpr bool traps = false;static constexpr bool tinyness_before = false;static constexpr float_round_style round_style = round_toward_zero;};}

For all members declaredstatic constexprin thenumeric_limitstemplate, specializations shall define these values in such a way that they are usable as constant expressions.

For thenumeric_limitsprimary template, all data members are value-initialized and all member functions return a value-initialized object.

[Note 1:

This means all members have zero or false values unless numeric_limits is specialized for a type.

— _end note_]

Specializations shall be provided for each arithmetic type, both floating-point and integer, includingbool.

The memberis_specializedshall betruefor all such specializations ofnumeric_limits.

The value of each member of a specialization ofnumeric_limits on a cv-qualified typecv T shall be equal to the value of the corresponding member of the specialization on the unqualified type T.

Non-arithmetic standard types, such ascomplex, shall not have specializations.