UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::TSharedString< CharType > Class Template Reference

#include <SharedString.h>

Public Types

using ElementType = CharType
 

Public Member Functions

 TSharedString ()=default
 
 TSharedString (TSharedString &&String)
 
 TSharedString (const TSharedString &String)
 
TSharedStringoperator= (TSharedString &&String)
 
TSharedStringoperator= (const TSharedString &String)
 
 TSharedString (TStringView< CharType > String)
 
TSharedStringoperator= (TStringView< CharType > String)
 
 ~TSharedString ()
 
void Reset ()
 
bool IsEmpty () const
 
int32 Len () const
 
const CharType * operator* () const
 

Static Public Attributes

static const TSharedString Empty
 

Friends

constexpr const CharType * GetData (const TSharedString String)
 
constexpr auto GetNum (const TSharedString String)
 
uint32 GetTypeHash (const TSharedString &String)
 
bool operator== (const TSharedString &Lhs, const TSharedString &Rhs)
 
bool operator< (const TSharedString &Lhs, const TSharedString &Rhs)
 

Detailed Description

template<typename CharType>
class UE::TSharedString< CharType >

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.

Member Typedef Documentation

◆ ElementType

template<typename CharType >
using UE::TSharedString< CharType >::ElementType = CharType

Constructor & Destructor Documentation

◆ TSharedString() [1/4]

template<typename CharType >
UE::TSharedString< CharType >::TSharedString ( )
default

◆ TSharedString() [2/4]

template<typename CharType >
UE::TSharedString< CharType >::TSharedString ( TSharedString< CharType > &&  String)
inline

◆ TSharedString() [3/4]

template<typename CharType >
UE::TSharedString< CharType >::TSharedString ( const TSharedString< CharType > &  String)

◆ TSharedString() [4/4]

template<typename CharType >
UE::TSharedString< CharType >::TSharedString ( TStringView< CharType >  String)

Allocates a copy of the string and constructs this as a reference to it.

◆ ~TSharedString()

template<typename CharType >
UE::TSharedString< CharType >::~TSharedString ( )
inline

Member Function Documentation

◆ IsEmpty()

template<typename CharType >
bool UE::TSharedString< CharType >::IsEmpty ( ) const
inline

Returns true if the referenced string is empty.

◆ Len()

template<typename CharType >
int32 UE::TSharedString< CharType >::Len ( ) const
inline

Returns the length of the referenced string excluding the null terminator.

◆ operator*()

template<typename CharType >
const CharType * UE::TSharedString< CharType >::operator* ( ) const
inline

Returns a pointer to the start of the referenced null-terminated string.

◆ operator=() [1/3]

template<typename CharType >
TSharedString< CharType > & UE::TSharedString< CharType >::operator= ( const TSharedString< CharType > &  String)

◆ operator=() [2/3]

template<typename CharType >
TSharedString< CharType > & UE::TSharedString< CharType >::operator= ( TSharedString< CharType > &&  String)

◆ operator=() [3/3]

template<typename CharType >
TSharedString< CharType > & UE::TSharedString< CharType >::operator= ( TStringView< CharType >  String)

Allocates a copy of the string and assigns this as a reference to it.

◆ Reset()

template<typename CharType >
void UE::TSharedString< CharType >::Reset ( )
inline

Resets this to reference the empty string.

Friends And Related Symbol Documentation

◆ GetData

template<typename CharType >
constexpr const CharType * GetData ( const TSharedString< CharType >  String)
friend

◆ GetNum

template<typename CharType >
constexpr auto GetNum ( const TSharedString< CharType >  String)
friend

◆ GetTypeHash

template<typename CharType >
uint32 GetTypeHash ( const TSharedString< CharType > &  String)
friend

◆ operator<

template<typename CharType >
bool operator< ( const TSharedString< CharType > &  Lhs,
const TSharedString< CharType > &  Rhs 
)
friend

◆ operator==

template<typename CharType >
bool operator== ( const TSharedString< CharType > &  Lhs,
const TSharedString< CharType > &  Rhs 
)
friend

Member Data Documentation

◆ Empty

template<typename CharType >
const TSharedString< CharType > UE::TSharedString< CharType >::Empty
inlinestatic

An empty string provided mainly for returning a reference to an empty TSharedString.


The documentation for this class was generated from the following file: