Hello.
I ran into an issue in the following code, where sv
cannot be declared constexpr
:
// error: constexpr variable 'sv' must be initialized by a constant expression constexpr auto sv = FStringView(TEXT("foo"));
This happens because TCString<T>::Strlen(const CharType*)
is not marked constexpr
.
Although TStringView::TStringView(const CharType*)
is itself marked constexpr
, it can never produce a compile-time constant since it calls the non-constexpr
TCString<T>::Strlen(const CharType*)
.
Therefore, either:
- Remove the
constexpr
fromTStringView::TStringView(const CharType*)
, - Or mark
TCString<T>::Strlen(const CharType* String)
asconstexpr
.
The latter would require making FPlatformString::Strlen
constexpr‐capable. On C++17 and later, that should really resolve to std::char_traits<TCHAR>::length
, which is a constexpr
function.