Navigation
API > API/Runtime > API/Runtime/Core
A reference to an immutable, shared, reference-counted string.
Prefer TStringView when there is a clear single point of ownership with a longer lifetime than the references to the string. This type is meant for cases where a shared string does not have an obvious owner or where the lifetime is not easy to manage.
The string is stored as a pointer to the start of the null-terminated string which is preceded by a 4-byte reference count and a 4-byte size.
| Name | TSharedString |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/SharedString.h |
| Include Path | #include "Containers/SharedString.h" |
| Source | /Engine/Source/Runtime/Core/Public/Containers/StringFwd.h |
Syntax
template<typename CharType>
class TSharedString
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Containers/SharedString.h | |||
TSharedString
(
TSharedString&& String |
Containers/SharedString.h | ||
TSharedString
(
const TSharedString& String |
Containers/SharedString.h | ||
TSharedString
(
TStringView< CharType > String |
Allocates a copy of the string and constructs this as a reference to it. | Containers/SharedString.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TSharedString() |
Containers/SharedString.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | CharType | Containers/SharedString.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Empty | const TSharedString | An empty string provided mainly for returning a reference to an empty TSharedString. | Containers/SharedString.h |
| NullChar | CharType | Containers/SharedString.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Chars | CharType * | Containers/SharedString.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool IsEmpty() |
Returns true if the referenced string is empty. | Containers/SharedString.h | |
int32 Len() |
Returns the length of the referenced string excluding the null terminator. | Containers/SharedString.h | |
void Reset() |
Resets this to reference the empty string. | Containers/SharedString.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AddRef
(
CharType* Chars |
Containers/SharedString.h | ||
static void Release
(
CharType* Chars |
Containers/SharedString.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
const CharType * operator*() |
Returns a pointer to the start of the referenced null-terminated string. | Containers/SharedString.h | |
TSharedString & operator=
(
TSharedString&& String |
Containers/SharedString.h | ||
TSharedString & operator=
(
const TSharedString& String |
Containers/SharedString.h | ||
TSharedString & operator=
(
TStringView< CharType > String |
Allocates a copy of the string and assigns this as a reference to it. | Containers/SharedString.h |