Skip to main content

value Struct Template

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> { ... }

Included Headers

Base struct

structvalue_base_<T>

Base struct template providing common storage and accessors for runtime value-wrapper types. More...

Derived Structs

struct_t<T>

Deprecated generic strongly-typed wrapper for explicit type conversion. More...

structto_t<T>

Generic strongly-typed wrapper for explicit type conversion. More...

Public Member Typedefs Index

template <class T>
usingvalue_type = T

The type of the stored value. More...

template <class T>
usingvalue_type = T

The type of the stored value. More...

Public Constructors Index

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

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 noexcept

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

template <class T>
constexproperator T () const noexcept

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

Public Member Functions Index

template <class T>
constexpr Tget (void) const noexcept

Getter for the stored value. More...

template <class T>
constexpr Tget (void) const noexcept

Getter for the stored value. More...

Public Member Attributes Index

template <class T>
Tepsilon = T{}

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

template <class T>
Tvalue_

The stored value. More...

template <class T>
Tvalue_ {}

The stored value. 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. The stored value, explicit conversion operator, and getter are provided by the value_base_ base.

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

Public Member Typedefs

value_type

template <class T>
using micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_type =

The type of the stored value.

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

514 using value_type = T;

value_type

template <class T>
using micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_type = T

The type of the stored value.

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

514 using value_type = T;

Public Constructors

value()

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

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.

Delegates to value_base_<T>{ _value } and stores the supplied precision in epsilon.

Declaration at line 761 of file type-traits.h, definition at line 193 of file type-traits-inlines.h.

193 constexpr value<T>::value (const T& _value, const T precision) noexcept
194 : value_base_<T>{ _value }, epsilon{ precision }
195 {
196 }

Reference micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_base_.

Referenced by micro_os_plus::micro_test_plus::_t< T >::_t and micro_os_plus::micro_test_plus::to_t< T >::to_t.

value()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value< T >::value (const T & val)
constexpr noexcept

Constructs a floating point value with default precision.

Parameters
val

The floating point value to be stored.

Delegates to value_base_<T>{ _value } to initialise the base.

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

Declaration at line 768 of file type-traits.h, definition at line 179 of file type-traits-inlines.h.

179 constexpr value<T>::value (const T& _value) noexcept
180 : value_base_<T>{ _value }
181 {
182 }

Reference micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_base_.

Public Operators

operator T()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value_base_< T >::operator T ()
explicit nodiscard constexpr noexcept

Explicit conversion operator to the underlying value type.

Returns

The stored value as type T.

Allows explicit conversion to the encapsulated value.

Declaration at line 529 of file type-traits.h, definition at line 83 of file type-traits-inlines.h.

83 operator T () const noexcept
84 {
85 return value_;
86 }

operator T()

template <class T>
micro_os_plus::micro_test_plus::type_traits::value_base_< T >::operator T ()
explicit nodiscard constexpr noexcept

Explicit conversion operator to the underlying value type.

Returns

The stored value as type T.

Allows explicit conversion to the encapsulated value.

Declaration at line 529 of file type-traits.h, definition at line 83 of file type-traits-inlines.h.

83 operator T () const noexcept
84 {
85 return value_;
86 }

References micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_base_ and micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_.

Public Member Functions

get()

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value_base_< T >::get (void)
nodiscard constexpr noexcept

Getter for the stored value.

Parameters

None.

Returns

The stored value.

Returns the stored value by value.

Declaration at line 539 of file type-traits.h, definition at line 94 of file type-traits-inlines.h.

94 value_base_<T>::get (void) const noexcept
95 {
96 return value_;
97 }

get()

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value_base_< T >::get (void)
nodiscard constexpr noexcept

Getter for the stored value.

Parameters

None.

Returns

The stored value.

Returns the stored value by value.

Declaration at line 539 of file type-traits.h, definition at line 94 of file type-traits-inlines.h.

94 value_base_<T>::get (void) const noexcept
95 {
96 return value_;
97 }

Reference micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_.

Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.

Public Member Attributes

epsilon

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value< T >::epsilon = T{}

The epsilon value used for floating-point comparisons.

This instance member defines the precision for comparisons. It is set via the constructor, either explicitly or computed as a default based on the number of decimal digits in the value. Each instance carries its own epsilon, so two value<T> objects with different precisions do not interfere with each other.

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

753 T epsilon = T{};

value_

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_

The stored value.

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

544 T value_{};

value_

template <class T>
T micro_os_plus::micro_test_plus::type_traits::value_base_< T >::value_ {}

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


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.