Skip to main content

The value Struct Template Reference

Struct template representing a floating point value with precision control. More...

Declaration

template <class T> struct micro_os_plus::micro_test_plus::type_traits::value<T, type_traits::requires_t< type_traits::is_floating_point_v< T > >> { ... }

Included Headers

Base struct

structop

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

Public Member Typedefs Index

template <class T>
usingvalue_type = T

The type of the encapsulated value. More...

Public Constructors Index

template <class T>
constexprvalue (const T &_value, const T precision)

Constructs a floating point value with a specified precision. More...

template <class T>
constexprvalue (const T &val)

Constructs a floating point value with default precision. More...

Public Operators Index

template <class T>
constexproperator T () const

Explicit conversion operator to the underlying value type. More...

Public Member Functions Index

template <class T>
constexpr auto get (void) const -> decltype(auto)

Getter for the encapsulated value. More...

Public Member Attributes Index

template <class T>
Tvalue_ {}

The encapsulated floating point value. More...

Public Static Attributes Index

template <class T>
static autoepsilon = T{}

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

Description

Struct template representing a floating point value with precision control.

Template Parameters
T

The floating point type to be encapsulated.

The value struct template specialisation for floating point types encapsulates a value of type T and provides an associated epsilon for precision control during comparisons. It inherits from type_traits::op to enable unified handling within the µTest++ framework's type traits and metaprogramming utilities.

This struct template exposes the value via a member variable, a getter method, and an explicit conversion operator. The epsilon member defines the precision used for floating point comparisons and can be set explicitly or computed as a default based on the number of decimal digits in the value.

This specialisation is intended for use cases where floating point values require controlled precision, supporting advanced template metaprogramming and type-safe comparisons within the framework.

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

Public Member Typedefs

value_type

template <class T>
using micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::value_type = T

The type of the encapsulated value.

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

1056 using value_type = T;

Public Constructors

value()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::value (const T & _value, const T precision)
inline constexpr

Constructs a floating point value with a specified precision.

Parameters
_value

The floating point value to be stored.

precision

The epsilon value to be used for comparisons.

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

1074 constexpr value (const T& _value, const T precision) : value_{ _value }
1075 {
1076 epsilon = precision;
1077 }

References epsilon and value_.

Referenced by value.

value()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::value (const T & val)
inline constexpr

Constructs a floating point value with default precision.

Parameters
val

The floating point value to be stored.

The epsilon is computed as 1 divided by 10 raised to the number of decimal digits in the value.

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

1088 constexpr /*explicit(false)*/ value (const T& val)
1089 : value{ val,
1090 T (1)
1091 / math::pow (T (10),
1092 math::den_size<unsigned long long> (val)) }
1093 {
1094 }

Reference value.

Public Operators

operator T()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::operator T ()
inline explicit nodiscard constexpr

Explicit conversion operator to the underlying value type.

Returns

The stored value as type T.

Allows explicit conversion to the encapsulated floating point value.

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

1105 operator T () const
1106 {
1107 return value_;
1108 }

Reference value_.

Public Member Functions

get()

template <class T>
decltype(auto) micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::get (void)
inline nodiscard constexpr

Getter for the encapsulated value.

Parameters

None.

Returns

The value of type T.

Returns the stored floating point value.

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

1121 get (void) const
1122 {
1123 return value_;
1124 }

References get and value_.

Referenced by get.

Public Member Attributes

value_

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::value_ {}

The encapsulated floating point value.

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

Referenced by value, get and operator T.

Public Static Attributes

epsilon

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::value< T, type_traits::requires_t< type_traits::is_floating_point_v< T > > >::epsilon = T{}
static

The epsilon value used for floating point comparisons.

This static inline member defines the precision for comparisons. It can be set explicitly via the constructor or computed as a default based on the number of decimal digits in the value.

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

1066 static inline auto epsilon = T{}; // Why static?

Referenced by value.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.