micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::extension::checkable Concept Reference

Concept satisfied when a type can be used as a test expression in expect() or require(). More...

#include <extension.h>

Concept definition

template<class T>
concept checkable = is_op<T>
and requires (const T& t) { t ? true : false; })
Concept satisfied by the wrappers of a bool, whose condition is ambiguous.
Definition extension.h:216
Concept satisfied when a type is contextually convertible to bool, but is most likely not a condition...
Definition extension.h:239
Concept satisfied when a type can be used as a test expression in expect() or require().
Definition extension.h:403
Concept satisfied when a type is a framework expression type.
Definition extension.h:320

Detailed Description

Template Parameters
TThe type to be checked.

The checkable concept is satisfied when T is either a framework expression type (see is_op) or a type contextually convertible to bool, as the condition of an if statement is. This includes the types with an explicit operator bool, such as std::optional, std::unique_ptr, std::shared_ptr, and std::function, but not the scoped enumerations, which only a cast converts, nor the types satisfying suspicious_condition (the arrays, the functions, the pointers to functions, to members, and to characters), which would make the check pass by mistake, nor the wrappers of a bool (std::optional<bool>, and the smart pointers to bool), whose condition tests the wrapper, not the bool that it holds. It is used to constrain the expect() and require() function templates, and the operands of all_of(), any_of(), and negate(), ensuring that only sensible expression types are accepted, also when they are wrapped in a logical combinator; an application helper that forwards its argument to them uses it for the same constraint.

The condition of the conditional operator, which cannot be overloaded, is used to test the contextual conversion, applied to a const value, as expect() and require() receive it.

Definition at line 403 of file extension.h.