template<typename Ret, typename... Args>
Callback struct

Type-erased single-binding delegate — stores one member function or free function.

Template parameters
Ret Return type.
Args Argument types.

Internally holds a context pointer (bindObj) and a stateless thunk (stub) that performs the cast and dispatch. No heap allocation; trivially copyable.

Public types

using Fn = Ret(*)(void*, Args...)
Thunk signature: context pointer followed by call args.

Constructors, destructors, conversion operators

__attribute__((always_inline)) const
Invoke the bound function. Undefined behaviour if IsBound() is false.

Public functions

template<typename T, Ret(T::*)(Args...) MemFn>
void Bind(T* obj)
Bind a member function. Stores the object pointer and synthesizes a thunk.
void BindStatic(Fn fn, void* ctx = nullptr)
Bind a free function or capturing-context thunk.
void Reset()
Clear the binding; IsBound() returns false afterward.
auto IsBound() const -> bool
Returns true if a function is currently bound.

Public variables

void* bindObj
Context pointer passed as first argument to the thunk.
Fn stub
Stateless dispatch thunk; null when unbound.

Function documentation

template<typename Ret, typename... Args> template<typename T, Ret(T::*)(Args...) MemFn>
void Callback<Ret, Args>::Bind(T* obj)

Bind a member function. Stores the object pointer and synthesizes a thunk.

Template parameters
T Object type that owns MemFn.
MemFn Pointer-to-member to dispatch to.

template<typename Ret, typename... Args>
void Callback<Ret, Args>::BindStatic(Fn fn, void* ctx = nullptr)

Bind a free function or capturing-context thunk.