micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::value_base< T > Struct Template Reference

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

#include "micro-os-plus/micro-test-plus.h"

Inheritance diagram for micro_os_plus::micro_test_plus::detail::value_base< T >:

Public Types

using op_type = op
 Marker identifying the framework expression types.
using value_type = T
 The type of the stored value.

Public Member Functions

constexpr value_base (const T &v) noexcept
 Constructs a value_base with the given value.
constexpr const T & get (void) const noexcept
 Getter for the stored value.
constexpr operator T () const noexcept
 Explicit conversion operator to the underlying value type.

Private Attributes

T value_ {}
 The stored value.

Detailed Description

template<class T>
struct micro_os_plus::micro_test_plus::detail::value_base< T >
Template Parameters
TThe type of the stored value.

The value_base struct template stores the value in a private member, and provides an explicit operator T() conversion and a get() accessor, shared by integral_constant, value<T>, and the floating-point specialisation of value<T>.

It declares the op_type marker, so that all derived types satisfy the extension::is_op concept without each struct needing to declare it.

It does not derive from the empty op struct: a type with an empty base and only floating-point members, like value<float>, is a homogeneous floating-point aggregate whose parameter passing with C++17 and later changed in GCC 10.1, and GCC emits a -Wpsabi note for each function passing or returning it by value, like approx(), on AArch64 and on 32-bit Arm with the hard-float ABI.

Definition at line 351 of file deprecated.h.

Member Typedef Documentation

◆ op_type

template<class T>
using micro_os_plus::micro_test_plus::detail::value_base< T >::op_type = op

Declared directly rather than inherited from op, to avoid the empty base; detected by the extension::is_op concept.

Definition at line 360 of file deprecated.h.

◆ value_type

template<class T>
using micro_os_plus::micro_test_plus::detail::value_base< T >::value_type = T

Exposed for use by generic code that inspects wrapper types.

Definition at line 368 of file deprecated.h.

Constructor & Destructor Documentation

◆ value_base()

template<class T>
micro_os_plus::micro_test_plus::detail::value_base< T >::value_base ( const T & v)
explicitconstexprnoexcept
Parameters
vThe value to be stored.

Stores the supplied value in the value_ member.

Definition at line 482 of file deprecated-inlines.h.

482 : value_{ v }
483 {
484 }
Base struct template providing common storage and accessors for run-time value-wrapper types.
Definition deprecated.h:352

References value_.

Referenced by micro_os_plus::micro_test_plus::detail::value< T >::value(), and operator T().

Member Function Documentation

◆ get()

template<class T>
const T & micro_os_plus::micro_test_plus::detail::value_base< T >::get ( void ) const
nodiscardconstexprnoexcept

Returns a reference, so that a wrapped object (for example a to_t<std::string>) is not copied each time it is compared or formatted.

Parameters
None.
Returns
A reference to the stored value.

Returns a const reference to the stored value, valid as long as the wrapper.

Definition at line 504 of file deprecated-inlines.h.

505 {
506 return value_;
507 }

References value_.

◆ operator T()

template<class T>
micro_os_plus::micro_test_plus::detail::value_base< T >::operator T ( ) const
explicitnodiscardconstexprnoexcept
Returns
The stored value as type T.

Allows explicit conversion to the encapsulated value.

Definition at line 491 of file deprecated-inlines.h.

493 {
494 return value_;
495 }

References value_base(), and value_.

Member Data Documentation

◆ value_

template<class T>
T micro_os_plus::micro_test_plus::detail::value_base< T >::value_ {}
private

Set by the constructor. Derived wrappers and comparators access it via get() or the explicit conversion operator.

Definition at line 408 of file deprecated.h.

Referenced by value_base(), get(), and operator T().


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