编译报错C4855解决方法
原代码
:
AsyncTask(ENamedThreads::GameThread, [=]()
{
if (FPlayWorldCommands::GlobalPlayWorldActions->TryExecuteAction(CommandInfo.Command.ToSharedRef()))
{
SendRequestSucceed(RequestID);
}
else
{
const FString Message = FString::Format(TEXT("Command '{0}' was not executed.\nRejected by Unreal Engine"),
{CommandInfo.CommandName.ToString()});
SendRequestFailed(RequestID, NotificationType::Message, Message);
}
});
新代码
:
AsyncTask(ENamedThreads::GameThread, [= , this]() //更改为C++20的语法规则
{
if (FPlayWorldCommands::GlobalPlayWorldActions->TryExecuteAction(CommandInfo.Command.ToSharedRef()))
{
SendRequestSucceed(RequestID);
}
else
{
const FString Message = FString::Format(TEXT("Command '{0}' was not executed.\nRejected by Unreal Engine"),
{CommandInfo.CommandName.ToString()});
SendRequestFailed(RequestID, NotificationType::Message, Message);
}
});