|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Function object that holds a callable and the additional arguments it is invoked with. More...
#include "micro-os-plus/micro-test-plus.h"
Public Member Functions | |
| template<typename C, typename... A> requires (sizeof...(A) > 0) | |
| constexpr | bound_callable (C &&callable, A &&... arguments) |
| Constructs the function object from a callable and the arguments. | |
| void | operator() (Self_T &self) |
| Invokes the stored callable. | |
Private Member Functions | |
| template<std::size_t... Is> | |
| void | invoke (Self_T &self, std::index_sequence< Is... >) |
| Invokes the stored callable with the stored arguments, unpacked by their indices. | |
Private Attributes | |
| std::tuple< Args_T... > | arguments_ |
| The stored arguments. | |
| Callable_T | callable_ |
| The stored callable. | |
Returned by bind_callable() when there are additional arguments. When invoked with a Self_T& reference, it invokes the stored callable with that reference, followed by the stored arguments, as non-const lvalues.
It replaces a lambda, since the function call operator of a lambda cannot be marked as always inlined in a way accepted by all the supported compilers; without optimisations, a separate frame for it would make the call chain of each nested test case longer.
|
explicitconstexpr |
Copies (or moves) the callable and the arguments into the object.
| C | The type of the callable, as passed. |
| A | The types of the arguments, as passed. |
| callable | The callable object. |
| arguments | The arguments passed to the callable after the leading reference. |
The callable and the arguments are forwarded to the constructors of the members, which store decayed copies.
Definition at line 370 of file test-inlines.h.
References bound_callable(), arguments_, and callable_.
Referenced by bound_callable().
|
inlineprivate |
Always inlined, as the function call operator.
| Is | The indices of the stored arguments. |
| self | The reference passed as the first argument. |
A function, a function pointer, or a function object is called directly, not through std::invoke(), which, without optimisations, adds three frames to the call chain; a pointer to a member, which only std::invoke() can call, is still passed to it.
Definition at line 399 of file test-inlines.h.
References arguments_, and callable_.
Referenced by operator()().
|
inline |
Always inlined, so that, without optimisations, it adds no frame between callable_ref::invoke_callable() and the callable.
| self | The reference passed as the first argument. |
Unpacks the stored arguments by their indices.
Definition at line 383 of file test-inlines.h.
References invoke().
|
private |
Copies of the arguments passed to bind_callable(), decayed; a reference parameter of the callable refers to the copy.
Definition at line 1020 of file test.h.
Referenced by bound_callable(), and invoke().
|
private |
A copy of the callable passed to bind_callable(), decayed, so a function is stored as a pointer.
Definition at line 1011 of file test.h.
Referenced by bound_callable(), and invoke().