blob: c4005d7cb87500e49b6a1dcf7c98de1dfea44f48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
class function_ref
{
public:
template<typename CallableT>
function_ref(CallableT &&t) noexcept
: m_Ptr((void *)std::addressof(t))
, m_ErasedFn([](void *ptr, Args... args) -> ReturnValue
{
// Type erasure lambda: cast ptr back to original type and dispatch the call
return (*reinterpret_cast<std::add_pointer_t<CallableT>>(ptr))(std::forward<Args>(args)...);
})
{}
};
|