constexpr version of FString

Hey all,

Quick question regarding the string containers in Unreal’s C++ - can you construct a valid constexpr for FString (or TStringView<>, or FName etc.). As far as I can tell this is possible in the modern C++ standard library (godbolt link) but when trying something similar for FString, the compiler spits this output out:

constexpr FString G_AUTOSAVE_SLOT_NAME = "Autosave";

// Example usage:
UGameplayStatics::AsyncSaveGameToSlot(SaveGameData, G_AUTOSAVE_SLOT_NAME, G_AUTOSAVE_USER_INDEX, SaveGameDelegate);

  [omitted]\JJEDefinitions.h(5): error C2131: expression did not evaluate to a constant
  [omitted]\JJEDefinitions.h(5): note: failure was caused by call of undefined function or one not declared 'constexpr'
  [omitted]\JJEDefinitions.h(5): note: see usage of 'FString::FString'
  [omitted]\JJEDefinitions.h(5): note: the call stack of the evaluation (the oldest call first) is
  [omitted]\JJEDefinitions.h(5): note: while evaluating function 'FString::FString(const ANSICHAR *)'
1 Like