Just finished a tiny but powerful C++ callback library: sy_callback.
- Footprint: Only 16 bytes (in 64 bit) (object pointer + thunk function pointer)
- Performance: Near 2x faster than std::function
- Safety: Works with non-trivial return types safely via RVO/move elision
- Flexible: Supports member functions, static functions, lambdas (capture/non-capture), functors, template function (auto cast)
- API: easy use, support target() like std::function
- No vtable needed: Lambda non-capture → no heap allocation, if is lambda capture or functors -> heap allocation (size will be 16 + sizeof lambda capture or functors)
It’s perfect for game engines, real-time systems, and performance-critical code where size and speed matter.
Usage examples, documentation and bernmarks are all available on github
Here : https://github.com/ShigamiYune/sy_callback.hpp
Top comments (0)