【UE5.3】编译报错C4855解决方法([C4855] “/std:c++20”中已弃用通过 “[=]“ 来隐式捕获 “this“)

编译报错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);
        }
    });

你可能感兴趣的:(ue5,前端)