Skip to content

Instantly share code, notes, and snippets.

@fortheday
Created May 9, 2018 08:38
Show Gist options
  • Save fortheday/d6f1fae9b660de1c27b1c09721c5bedc to your computer and use it in GitHub Desktop.
Save fortheday/d6f1fae9b660de1c27b1c09721c5bedc to your computer and use it in GitHub Desktop.
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();
}
@fortheday
Copy link
Author

FSimpleDelegate 내부에 힙할당이 있으면서 이동생성자를 구현했다면 rvalue를 사용한 것이 의미가 있을 수 있다. 그렇지 않다면 복사생성자가 호출될 것이다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment