libcaf
0.17.1
|
Describes a simple callback, usually implemented via lambda expression. More...
#include <callback.hpp>
Public Member Functions | |
virtual error | operator() (Ts...)=0 |
Related Functions | |
(Note that these are not member functions.) | |
template<class F > | |
select_callback< F >::type | make_callback (F fun) |
Creates a callback from a lambda expression. | |
Describes a simple callback, usually implemented via lambda expression.
Callbacks are used as "type-safe function objects" wherever an interface requires dynamic dispatching. The alternative would be to store the lambda in a std::function
, which adds another layer of indirection and requires a heap allocation. With the callback implementation of CAF, the object remains on the stack and does not cause more overhead than necessary.