Created
May 9, 2018 08:38
-
-
Save fortheday/d6f1fae9b660de1c27b1c09721c5bedc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FMyTasks | |
{ | |
private: | |
using TSinglecasterArray = TArray<FSimpleDelegate>; | |
TSinglecasterArray m_Singlecasters; | |
public: | |
void AddDelegate(FSimpleDelegate &&rvDelegate) | |
{ | |
m_Singlecasters.Add(rvDelegate); | |
} | |
void ExecuteDelegates(); | |
{ | |
for (const auto d : m_Singlecasters) | |
d.ExecuteIfBound(); | |
} | |
}; | |
void AMyActor::BeginPlay() | |
{ | |
Super::BeginPlay(); | |
FMyTasks tasks; | |
tasks.AddDelegate(FSimpleDelegate::CreateLambda([]() { LOGW("Task Step1"); })); | |
tasks.AddDelegate(FSimpleDelegate::CreateLambda([]() { LOGW("Task Step2"); })); | |
tasks.ExecuteDelegates(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FSimpleDelegate 내부에 힙할당이 있으면서 이동생성자를 구현했다면 rvalue를 사용한 것이 의미가 있을 수 있다. 그렇지 않다면 복사생성자가 호출될 것이다.