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

Common base struct template for binary comparators. More...

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

Inheritance diagram for micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >:

Public Types

using op_type = op
 Marker identifying the framework expression types.

Public Member Functions

template<class L, class R>
constexpr binary_op (L &&lhs, R &&rhs, bool value)
 Constructs a binary comparator with the given operands and pre-computed result.
constexpr decltype(auto) lhs (void) const
 Retrieves the left-hand operand.
constexpr operator bool () const
 Conversion operator to boolean.
constexpr decltype(auto) rhs (void) const
 Retrieves the right-hand operand.

Private Attributes

Lhs_T lhs_
 Stores the left-hand operand.
Rhs_T rhs_
 Stores the right-hand operand.
const bool value_ {}
 Stores the result of the comparison.

Detailed Description

template<class Lhs_T, class Rhs_T>
struct micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >

This base struct stores two operands (left-hand and right-hand) along with the pre-computed boolean result of a binary comparison. Derived structs such as compare_op, and_op, and or_op inherit from this to provide relational and logical operations. The comparison result is computed at construction time and stored, so that the reporters and the logical operations read it without evaluating the operands again.

Template Parameters
Lhs_TThe type of the stored left-hand operand, either the operand type, or a const reference to it (see stored_operand_t).
Rhs_TThe type of the stored right-hand operand, either the operand type, or a const reference to it.

Definition at line 342 of file detail.h.

Member Typedef Documentation

◆ op_type

Detected by the extension::is_op concept, and inherited by all types derived from op.

Definition at line 128 of file extension.h.

Constructor & Destructor Documentation

◆ binary_op()

template<class Lhs_T, class Rhs_T>
template<class L, class R>
micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op ( L && lhs,
R && rhs,
bool value )
constexpr

The operands are forwarded to the members, so that the rvalues are moved, not copied.

Template Parameters
LThe type of the left-hand operand argument.
RThe type of the right-hand operand argument.
Parameters
lhsThe left-hand operand.
rhsThe right-hand operand.
valueThe pre-computed boolean result of the comparison.

Stores the two operands and the pre-computed boolean result of the comparison in the corresponding private members.

Definition at line 155 of file detail-inlines.h.

157 value_{ value }
158 {
159 }
Common base struct template for binary comparators.
Definition detail.h:343
constexpr decltype(auto) lhs(void) const
Retrieves the left-hand operand.
Rhs_T rhs_
Stores the right-hand operand.
Definition detail.h:418
const bool value_
Stores the result of the comparison.
Definition detail.h:426
Lhs_T lhs_
Stores the left-hand operand.
Definition detail.h:410
constexpr decltype(auto) rhs(void) const
Retrieves the right-hand operand.

References lhs(), lhs_, rhs(), rhs_, and value_.

Referenced by micro_os_plus::micro_test_plus::detail::and_op< Lhs_T, Rhs_T >::and_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::or_op< Lhs_T, Rhs_T >::or_op(), and operator bool().

Member Function Documentation

◆ lhs()

template<class Lhs_T, class Rhs_T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs ( void ) const
nodiscardconstexpr

The operand is unwrapped with detail::unwrap() and returned by reference, so that formatting it does not copy it.

Parameters
None.
Returns
The extracted left-hand operand.

Returns the value of the left-hand operand, unwrapped by detail::unwrap() if it is a framework wrapper type; the stored operand is not copied.

Definition at line 181 of file detail-inlines.h.

182 {
183 return detail::unwrap (lhs_);
184 }
decltype(auto) constexpr unwrap(const T &t)
Returns the value wrapped by a framework type, or the operand itself.

References lhs(), lhs_, and micro_os_plus::micro_test_plus::detail::unwrap().

Referenced by micro_os_plus::micro_test_plus::detail::and_op< Lhs_T, Rhs_T >::and_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), binary_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::or_op< Lhs_T, Rhs_T >::or_op(), and lhs().

◆ operator bool()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::operator bool ( ) const
nodiscardconstexpr
Parameters
None.
Returns
The result of the comparison.

Returns the pre-computed boolean result stored by the derived comparator's constructor.

Definition at line 167 of file detail-inlines.h.

169 {
170 return value_;
171 }

References binary_op(), and value_.

◆ rhs()

template<class Lhs_T, class Rhs_T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs ( void ) const
nodiscardconstexpr

The operand is unwrapped with detail::unwrap() and returned by reference, so that formatting it does not copy it.

Parameters
None.
Returns
The extracted right-hand operand.

Returns the value of the right-hand operand, unwrapped by detail::unwrap() if it is a framework wrapper type; the stored operand is not copied.

Definition at line 194 of file detail-inlines.h.

195 {
196 return detail::unwrap (rhs_);
197 }

References rhs(), rhs_, and micro_os_plus::micro_test_plus::detail::unwrap().

Referenced by micro_os_plus::micro_test_plus::detail::and_op< Lhs_T, Rhs_T >::and_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), binary_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::or_op< Lhs_T, Rhs_T >::or_op(), and rhs().

Member Data Documentation

◆ lhs_

template<class Lhs_T, class Rhs_T>
Lhs_T micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs_
private

A value, moved from a temporary or copied from a named operand, or, for a named operand that cannot be copied, a const reference to it (see stored_operand_t). It is not const, so that a temporary expression can be moved into an enclosing one.

Definition at line 410 of file detail.h.

Referenced by binary_op(), and lhs().

◆ rhs_

template<class Lhs_T, class Rhs_T>
Rhs_T micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs_
private

Stored as the left-hand operand is.

Definition at line 418 of file detail.h.

Referenced by binary_op(), and rhs().

◆ value_

template<class Lhs_T, class Rhs_T>
const bool micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::value_ {}
private

Computed once, by the derived comparator constructor.

Definition at line 426 of file detail.h.

Referenced by binary_op(), and operator bool().


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