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

Logical NOT comparator struct template. More...

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

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

Public Types

using op_type = op
 Marker identifying the framework expression types.

Public Member Functions

template<class U>
requires (not std::is_same_v<std::remove_cvref_t<U>, not_op<T>>)
constexpr not_op (U &&t)
 Constructs a logical NOT comparator for the given operand.
constexpr decltype(auto) operand (void) const
 Retrieves the wrapped operand expression.
constexpr operator bool () const
 Conversion operator to boolean.

Private Attributes

T t_
 Stores the operand.
const bool value_ {}
 Stores the result of the operation.

Detailed Description

template<class T>
struct micro_os_plus::micro_test_plus::detail::not_op< T >

Derived from unary_op, this struct negates a single sub-expression, enabling test writers to assert that a condition does not hold. The negation result is computed at construction time.

A temporary is moved into the comparator, and a named sub-expression is copied (see stored_operand_t).

There is no deduction guide: with a single argument that is itself a not_op, the class template argument deduction prefers the copy deduction candidate, so not_op{ inner } would copy inner instead of negating it. Name the template argument instead, as not_op<stored_operand_t<T>>{ t }.

Template Parameters
TThe type of the stored sub-expression, either its type, or a const reference to it.

Definition at line 1194 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

◆ not_op()

template<class T>
requires (not std::is_same_v<std::remove_cvref_t<U>, not_op<T>>)
template<class U>
requires (not std::is_same_v<std::remove_cvref_t<U>, not_op<T>>)
micro_os_plus::micro_test_plus::detail::not_op< T >::not_op ( U && t)
explicitconstexpr

The result is computed from the argument, before it is forwarded to the base. The constraint leaves the copies and the moves of a not_op to the implicit constructors.

Template Parameters
UThe type of the operand argument.
Parameters
tThe operand to be negated.

Evaluates the logical negation not static_cast<bool>(t) and passes the result to the unary_op base class constructor.

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

1079 : unary_op<T>{ std::forward<U> (t), not static_cast<bool> (t) }
1080 {
Logical NOT comparator struct template.
Definition detail.h:1195
constexpr unary_op(U &&t, bool value)
Constructs a unary comparator with the given operand and pre-computed result.

References not_op(), and micro_os_plus::micro_test_plus::detail::unary_op< T >::unary_op().

Referenced by not_op().

Member Function Documentation

◆ operand()

template<class T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::unary_op< T >::operand ( void ) const
nodiscardconstexprinherited

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

Parameters
None.
Returns
The extracted operand value.

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

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

142 {
143 return detail::unwrap (t_);
144 }
decltype(auto) constexpr unwrap(const T &t)
Returns the value wrapped by a framework type, or the operand itself.

References operand(), t_, and micro_os_plus::micro_test_plus::detail::unwrap().

Referenced by operand().

◆ operator bool()

template<class T>
micro_os_plus::micro_test_plus::detail::unary_op< T >::operator bool ( ) const
nodiscardconstexprinherited
Parameters
None.
Returns
The result of the operation.

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

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

130 {
131 return value_;
132 }
const bool value_
Stores the result of the operation.
Definition detail.h:317

References unary_op(), and value_.

Member Data Documentation

◆ t_

template<class T>
T micro_os_plus::micro_test_plus::detail::unary_op< T >::t_
privateinherited

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 309 of file detail.h.

Referenced by unary_op(), and operand().

◆ value_

template<class T>
const bool micro_os_plus::micro_test_plus::detail::unary_op< T >::value_ {}
privateinherited

Computed once, by the derived comparator constructor.

Definition at line 317 of file detail.h.

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


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