floating_point_constant Struct Template
Struct template representing a generic floating-point constant with custom size and precision. More...
Declaration
struct micro_os_plus::micro_test_plus::type_traits::floating_point_constant<T, N, D, Size, P> { ... }
Included Headers
Base struct
| struct | op |
|
Empty base struct for the framework expression types. More... | |
Public Member Typedefs Index
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| using | op_type = op |
|
Marker identifying the framework expression types. More... | |
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| using | value_type = T |
|
The type of the stored value. More... | |
Public Operators Index
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| constexpr | operator T () const noexcept |
|
Explicit conversion operator to the underlying value type. More... | |
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| constexpr auto | operator- () const noexcept |
|
Unary minus operator. More... | |
Public Member Functions Index
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| constexpr T | get (void) const noexcept |
|
Getter for the compile-time constant value. More... | |
Public Static Attributes Index
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| static constexpr auto | epsilon = T (1) / math::pow (T (10), Size) |
|
The epsilon value used for floating-point comparisons. More... | |
template <class T, auto N, auto D, auto Size, auto P = 1> | |
| static constexpr auto | value = T (P) * (T (N) + (T (D) / math::pow (T (10), Size))) |
|
The compile-time constant value. More... | |
Description
Struct template representing a generic floating-point constant with custom size and precision.
- Template Parameters
-
T The floating-point type (e.g., float, double).
N The integral part of the constant value.
D The digits of the fractional part of the constant value, as returned by math::den() (e.g. 25 for 1.25).
Size The number of decimal digits, the scale of D, as returned by math::den_size() (e.g. 2 for 1.25).
P The sign of the value (1 for positive, -1 for negative). Defaults to 1.
The floating_point_constant struct template provides a compile-time constant value of a floating-point type, supporting custom size and precision. It inherits from op directly rather than from value_base<T>, since its value is the compile-time value constant, and it needs no run-time storage; the struct is empty, and the literal operators create it with {}, without a constructor. Having no non-static floating-point members, it is not a homogeneous floating-point aggregate, so the -Wpsabi note described for value_base does not apply to it, despite its empty base. On 32-bit Arm, GCC emits another note, about a change in GCC 7.1, for each function passing a double or long double constant by value, since the earlier versions computed its alignment from its static double members; the framework does not pass the constants by value.
The value_type alias, explicit conversion operator, and get() accessor are provided directly by this struct. The compile-time epsilon and value static constants are retained, and a unary minus operator is provided to obtain the negative value as a new floating_point_constant instance.
Definition at line 555 of file deprecated.h.
Public Member Typedefs
op_type
|
Marker identifying the framework expression types.
Detected by the extension::is_op concept, and inherited by all types derived from op.
Definition at line 128 of file extension.h.
value_type
|
The type of the stored value.
Provided directly, since this struct does not derive from value_base.
Definition at line 567 of file deprecated.h.
Public Operators
operator T()
| explicit nodiscard constexpr noexcept |
Explicit conversion operator to the underlying value type.
- Returns
The compile-time constant as type T.
Returns the compile-time constant value as type T.
Declaration at line 593 of file deprecated.h, definition at line 605 of file deprecated-inlines.h.
operator-()
| nodiscard constexpr noexcept |
Unary minus operator.
- Returns
A floating_point_constant with negated sign parameter.
Returns a new floating_point_constant instance representing the negative of the current value by flipping the sign parameter P.
Declaration at line 611 of file deprecated.h, definition at line 628 of file deprecated-inlines.h.
Public Member Functions
get()
| nodiscard constexpr noexcept |
Getter for the compile-time constant value.
- Parameters
None.
- Returns
The compile-time constant as type T.
Returns the compile-time constant value as type T.
Declaration at line 603 of file deprecated.h, definition at line 616 of file deprecated-inlines.h.
Public Static Attributes
epsilon
| constexpr static |
The epsilon value used for floating-point comparisons.
Calculated as 1 divided by 10 raised to the power of Size, i.e. one unit of the last decimal digit of the literal.
Definition at line 576 of file deprecated.h.
value
| constexpr static |
The compile-time constant value.
Computed as P * (N + D / 10^Size).
Definition at line 584 of file deprecated.h.
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.