Skip to content

Latest commit

 

History

History
80 lines (53 loc) · 2.47 KB

closure_templates.rst

File metadata and controls

80 lines (53 loc) · 2.47 KB

Closure templates

zenoh-c closure is a structure with 3 fields: context pointer context, callback call and finalizer drop. Context is a pointer to closure data, callback is a function pointer and finalizer is a function pointer which is called when closure is destroyed. Example of zenoh-c closure:

zenoh-cpp closures are wrappers around zenoh-c closures. These wrappers allows to construct closures from any callable C++ object, like lambda or function pointer.

All zenoh-cpp closures are based on the one of the following templates: :cppzenohcxx::ClosureConstPtrParam and :cppzenohcxx::ClosureMoveParam. First one accepts const ZCPP_PARAM&, second one accepts ZCPP_PARAM&&.

These templates allows to construct closures from any callable C++ object:

zenohcxx::ClosureConstRefParam

zenohcxx::ClosureMoveParam