Reuse code from Bind lambda in Function
This commit is contained in:
@@ -95,12 +95,8 @@ public:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
Function(const T& lambda)
|
Function(const T& lambda)
|
||||||
{
|
{
|
||||||
_lambda = (Lambda*)Allocator::Allocate(sizeof(Lambda) + sizeof(T));
|
_lambda = nullptr;
|
||||||
_lambda->Refs = 1;
|
Bind<T>(lambda);
|
||||||
_lambda->Dtor = [](void* callee) -> void { static_cast<T*>(callee)->~T(); };
|
|
||||||
_function = [](void* callee, Params ... params) -> ReturnType { return (*static_cast<T*>(callee))(Forward<Params>(params)...); };
|
|
||||||
_callee = (byte*)_lambda + sizeof(Lambda);
|
|
||||||
new(_callee) T(lambda);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Function(const Function& other)
|
Function(const Function& other)
|
||||||
|
|||||||
Reference in New Issue
Block a user