xbot/c_callback.hpp

15 lines
334 B
C++
Raw Permalink Normal View History

2023-11-27 18:47:32 -08:00
#pragma once
template <typename> struct CCallback_;
template <typename F, typename R, typename... Ts>
struct CCallback_<R (F::*) (Ts...) const>
{
static R invoke(Ts... args, void* u)
{
return (*reinterpret_cast<F*>(u))(args...);
}
};
template <typename F>
using CCallback = CCallback_<decltype(&F::operator())>;