From 2daec98fd7b483af73fc100b024ed264954a1713 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Tue, 7 Dec 2021 18:27:02 +0100 Subject: [PATCH] Reuse code from Bind lambda in Function --- Source/Engine/Core/Delegate.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Core/Delegate.h b/Source/Engine/Core/Delegate.h index 9269fec9d..1236b1cd7 100644 --- a/Source/Engine/Core/Delegate.h +++ b/Source/Engine/Core/Delegate.h @@ -95,12 +95,8 @@ public: template Function(const T& lambda) { - _lambda = (Lambda*)Allocator::Allocate(sizeof(Lambda) + sizeof(T)); - _lambda->Refs = 1; - _lambda->Dtor = [](void* callee) -> void { static_cast(callee)->~T(); }; - _function = [](void* callee, Params ... params) -> ReturnType { return (*static_cast(callee))(Forward(params)...); }; - _callee = (byte*)_lambda + sizeof(Lambda); - new(_callee) T(lambda); + _lambda = nullptr; + Bind(lambda); } Function(const Function& other)