26template <
typename FnPtr >
29template <
typename R,
typename... Args >
32 using fn_type = R ( * )(
void*, Args... );
45 template <
typename CB >
46 requires( !std::is_same_v< std::remove_cvref_t< CB >,
callback > &&
47 std::invocable< CB&, Args... > )
49 : fn( &trampoline< CB > )
54 R operator()( Args... args )
const {
return fn( ptr, args... ); }
56 explicit operator bool()
const {
return fn !=
nullptr; }
59 template <
typename CB >
60 static R trampoline(
void* p, Args... args )
62 return ( *
reinterpret_cast< CB*
>( p ) )( args... );
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: callback.hpp:17
A type-erasing wrapper for C-style callback + void* pairs.
Definition: callback.hpp:27