Skip to main content

floating_point_constant Struct Template

Struct template representing a generic floating point constant with custom size and precision. More...

Declaration

template <class T, auto N, auto D, auto Size, auto P = 1>
struct micro_os_plus::micro_test_plus::type_traits::floating_point_constant<T, N, D, Size, P> { ... }

Included Headers

Base struct

structop

Empty base struct for all operator types. More...

Public Member Typedefs Index

template <class T, auto N, auto D, auto Size, auto P = 1>
usingvalue_type = T

The type of the stored value. More...

Public Operators Index

template <class T, auto N, auto D, auto Size, auto P = 1>
constexproperator 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 autooperator- () const noexcept

Unary minus operator. More...

Public Member Functions Index

template <class T, auto N, auto D, auto Size, auto P = 1>
constexpr Tget (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 autoepsilon = T (1) / math::pow (T (10), Size - 1)

The epsilon value used for floating point comparisons. More...

template <class T, auto N, auto D, auto Size, auto P = 1>
static constexpr autovalue = 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 fractional part of the constant value.

Size

The number of decimal digits for the fractional part.

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>, which avoids introducing a user-provided constructor into the type and keeps it trivially default-constructible. This prevents the GCC ARM PSABI note about parameter-passing ABI changes that is emitted for non-trivially-constructible types under C++17.

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 616 of file type-traits.h.

Public Member Typedefs

value_type

template <class T, auto N, auto D, auto Size, auto P = 1>
using micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::value_type = T

The type of the stored value.

Definition at line 624 of file type-traits.h.

624 using value_type = T;

Public Operators

operator T()

template <class T, auto N, auto D, auto Size, auto P = 1>
micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::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 649 of file type-traits.h, definition at line 131 of file type-traits-inlines.h.

131 operator T () const noexcept
132 {
133 return value;
134 }

Reference micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::value.

operator-()

template <class T, auto N, auto D, auto Size, auto P = 1>
auto micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::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 667 of file type-traits.h, definition at line 154 of file type-traits-inlines.h.

155 {
156 return floating_point_constant<T, N, D, Size, -P>{};
157 }

Public Member Functions

get()

template <class T, auto N, auto D, auto Size, auto P = 1>
T micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::get (void)
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 659 of file type-traits.h, definition at line 142 of file type-traits-inlines.h.

143 {
144 return value;
145 }

Reference micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::value.

Public Static Attributes

epsilon

template <class T, auto N, auto D, auto Size, auto P = 1>
auto micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::epsilon = T (1) / math::pow (T (10), Size - 1)
constexpr static

The epsilon value used for floating point comparisons.

Calculated as 1 divided by 10 raised to the power of (Size - 1).

Definition at line 632 of file type-traits.h.

632 static constexpr auto epsilon = T (1) / math::pow (T (10), Size - 1);

value

template <class T, auto N, auto D, auto Size, auto P = 1>
auto micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::value = T (P) * (T (N) + (T (D) / math::pow (T (10), Size)))
constexpr static

The compile-time constant value.

Computed as P * (N + D / 10^Size).

Definition at line 640 of file type-traits.h.

641 = T (P) * (T (N) + (T (D) / math::pow (T (10), Size)));

Referenced by micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::get and micro_os_plus::micro_test_plus::type_traits::floating_point_constant< T, N, D, Size, P >::operator T.


The documentation for this struct was generated from the following files:


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.