Quantcast
Viewing all articles
Browse latest Browse all 28

Convert std::string to FString; the quick method

A quick method I use for transforming a C++ standard library string to an Unreal Engine FString is to call c_str(), the base c string export helper, on a std::string. Provided the result is being implicitly convert to an FString this method will work.

std::string a = “hello”;

FString b = a.c_str();

This method is shorter and simpler than the canonical method Epic Games recommends which calls for an explicit cast. An explicit cast is only required in cases where the compiler cannot otherwise deduce that the result should be an FString.


Viewing all articles
Browse latest Browse all 28

Trending Articles