powerd++
0.4.4
|
Implements a recursion safe std::function wrapper. More...
Public Types | |
typedef std::function< void(FunctionArgs...)> | function_t |
The callback function type. | |
Public Member Functions | |
Callback () | |
Default constructor, creates a non-callable handle. | |
Callback (function_t const &callback) | |
Construct from function. More... | |
Callback (function_t &&callback) | |
Construct from temporary function. More... | |
void | operator() (FunctionArgs... args) |
Forward call to callback functions. More... | |
Private Attributes | |
function_t | callback |
Storage for the callback function. | |
bool | called {false} |
Set if this handle is currently in use. | |
Implements a recursion safe std::function wrapper.
The purpose is to prevent recursive calls of a callback function handle, in cases when a callback function performs actions that cause a successive call of the callback function.
To avoid having to return a value when a successive function call occurs only functions returning void are valid callback functions.
This is not thread safe.
FunctionArgs | The argument types of the callback function |
|
inline |
Construct from function.
callback | The callback function |
|
inline |
Construct from temporary function.
callback | The callback function |
|
inline |
Forward call to callback functions.
args | The arguments to the callback function |
std::bad_function_call | In case this handler was default constructed or constructed from a nullptr |