Skip to main content

to_t Struct Template

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

Declaration

template <class T>
struct micro_os_plus::micro_test_plus::to_t<T> { ... }

Included Headers

Base struct

structvalue<T>

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

Public Member Typedefs Index

template <class T>
usingvalue_type = T

The type of the stored value. More...

Public Constructors Index

constexprto_t (const T &t)

Constructor for the strongly-typed wrapper. More...

Public Operators Index

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

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

Description

Generic strongly-typed wrapper for explicit type conversion.

Since

3.2.0

The to_t template provides a public, strongly-typed wrapper for any type T, enabling explicit conversion of dynamic values and expressions to a type recognised by the µTest++ comparators and reporting mechanisms.

This wrapper inherits from type_traits::value<T>, ensuring that the encapsulated value is treated as the specified type within the framework. It is particularly useful for enhancing type safety and clarity in test expressions, especially when working with user-defined or less common types.

Example

 MyType obj;
 auto wrapped = to_t<MyType>{obj}; // Explicitly treat obj as MyType for
 test comparison

This file is intended solely for internal use within the framework and should not be included directly by user code.

Definition at line 877 of file literals.h.

Public Member Typedefs

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

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 }

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 documentation for this struct was generated from the following files:


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.