Skip to main content

The floating_point_constant Struct Template Reference

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 constant value. More...

Public Operators Index

template <class T, auto N, auto D, auto Size, auto P = 1>
constexproperator value_type () const

Explicit conversion operator to value_type. More...

template <class T, auto N, auto D, auto Size, auto P = 1>
constexpr autooperator- () const

Unary minus operator. More...

Public Member Functions Index

template <class T, auto N, auto D, auto Size, auto P = 1>
constexpr autoget () const

Getter for the 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 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 to enable unified handling within the µTest++ framework's type traits and metaprogramming utilities.

This struct template exposes the constant value via a static member, a getter method, and explicit conversion operators. It also provides a unary minus operator to obtain the negative value as a new floating_point_constant instance. The epsilon member defines the precision used for floating point comparisons, calculated based on the specified size.

Definition at line 790 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 constant value.

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

795 using value_type = T;

Public Operators

operator value_type()

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 value_type ()
inline explicit nodiscard constexpr

Explicit conversion operator to value_type.

Returns

The constant value as type value_type.

Allows explicit conversion to the underlying floating point value type.

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

839 operator value_type () const
840 {
841 return value;
842 }

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- ()
inline nodiscard constexpr

Unary minus operator.

Returns

A floating_point_constant with value -value.

Returns a new floating_point_constant instance representing the negative of the current value.

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

824 operator-() const
825 {
826 return floating_point_constant<T, N, D, Size, -1>{};
827 }

Public Member Functions

get()

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 >::get ()
inline nodiscard constexpr

Getter for the constant value.

Returns

The constant value.

Returns the compile-time floating point constant value.

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

853 get () const
854 {
855 return value;
856 }

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

803 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 constant value.

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

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

812 = 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 value_type.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.