Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

How to fix this error: Error C2664 'void…

  1. User

    How to fix this error: Error C2664 'void RGN::Modules::Wallets::WalletsModule::CreateWalletAsync(std::string &,const std::function<void (RGN::Modules::Wallets::CreateWalletResponseData &)> &,const std::function<void (int,std::string)> &)': cannot convert argument 1 from 'std::string' to 'std::string &'

    void UBP_WalletsModule::CreateWallet(const FString& password, FCreateWalletSuccessResponse successEvent, FWalletsFailResponse failEvent) { WalletsModule::CreateWalletAsync(std::string(TCHAR_TO_UTF8(*password)), [successEvent](CreateWalletResponseData response) { json responseJson = response; FString responseJsonString = FString(responseJson.dump().c_str()); FBP_CreateWalletResponseData bpResponse; FJsonObjectConverter::JsonObjectStringToUStruct<FBP_CreateWalletResponseData>(responseJsonString, &bpResponse, 0, 0); successEvent.ExecuteIfBound(bpResponse); }, [failEvent](int code, std::string message) { failEvent.ExecuteIfBound(static_cast(code), FString(message.c_str())); } ); }

  2. Assistant

    The error message indicates that there is a problem with argument 1 in the function call WalletsModule::CreateWalletAsync(). The argument should be a reference to a std::string, but you are passing a std::string value.

    To fix this error, you need to change the argument type in the lambda function to accept a reference to std::string instead of std::string. Here's the updated code:

    void UBP_WalletsModule::CreateWallet(const FString& password,
        FCreateWalletSuccessResponse successEvent, FWalletsFailResponse failEvent) {
            std::string passwordStr(TCHAR_TO_UTF8(*password));
            WalletsModule::CreateWalletAsync(passwordStr,
                [successEvent](CreateWalletResponseData response) {
                    json responseJson = response;
                    FString responseJsonString = FString(responseJson.dump().c_str());
                    FBP_CreateWalletResponseData bpResponse;
                    FJsonObjectConverter::JsonObjectStringToUStruct<FBP_CreateWalletResponseData>(responseJsonString, &bpResponse, 0, 0);
                    successEvent.ExecuteIfBound(bpResponse);
                },
                [failEvent](int code, const std::string& message) {
                    failEvent.ExecuteIfBound(static_cast<int32>(code), FString(message.c_str()));
                }
            );
        }
    

    In this updated code, the password FString is converted to a std::string named passwordStr before passing it to CreateWalletAsync(). The lambda function for the failure case is also updated to accept a reference to std::string for the message parameter.