Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment > Class Template Reference

#include <InlineValue.h>

+ Collaboration diagram for TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >:

Public Member Functions

 TInlineValue ()
 
template<typename T , typename = typename TEnableIf<TPointerIsConvertibleFromTo<typename TDecay<T>::Type, BaseType>::Value>::Type>
 TInlineValue (T &&In)
 
template<typename... ArgTypes>
 TInlineValue (EInPlace, ArgTypes &&... Args)
 
 ~TInlineValue ()
 
 TInlineValue (TInlineValue &&In)
 
TInlineValueoperator= (TInlineValue &&In)
 
 TInlineValue (const TInlineValue &In)=delete
 
TInlineValueoperator= (const TInlineValue &In)=delete
 
template<typename T >
TEnableIf< TPointerIsConvertibleFromTo< typenameTDecay< T >::Type, BaseType >::Value, TInlineValue & >::Type operator= (T &&In)
 
void Reset (TInlineValue &&In)
 
void Reset ()
 
template<typename T , typename... ArgsType>
FORCEINLINE void Emplace (ArgsType &&... Args)
 
FORCEINLINE bool IsValid () const
 
FORCEINLINE BaseTypeGetValue () const
 
FORCEINLINE const BaseTypeGet (const BaseType &Default) const
 
FORCEINLINE BaseTypeGetPtr (BaseType *Default=nullptr) const
 
FORCEINLINE BaseTypeoperator* () const
 
FORCEINLINE BaseTypeoperator-> () const
 
voidReserve (uint32 InSize, uint32 InAlignment)
 

Private Types

enum  
 

Private Member Functions

template<typename T , typename... ArgsType>
void InitializeFrom (ArgsType &&... Args)
 
void ConditionallyAllocateObject (uint32 Size, uint32 Alignment)
 
void ConditionallyDestroyAllocation ()
 

Private Attributes

TAlignedBytes< MaxInlineSize, DefaultAlignmentData
 
bool bIsValid: 1
 
bool bInline: 1
 

Detailed Description

template<typename BaseType, uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
class TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >

A container type that houses an instance of BaseType in inline memory where it is <= MaxInlineSize, or in a separate heap allocation where it's > MaxInlineSize.

Can be viewed as a TUniquePtr with a small allocation optimization.

Definition at line 21 of file InlineValue.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
anonymous enum
private

~We cannot allow an allocation of less than the size of a pointer

Definition at line 229 of file InlineValue.h.

Constructor & Destructor Documentation

◆ TInlineValue() [1/5]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::TInlineValue ( )
inline

Default construction to an empty container

Definition at line 27 of file InlineValue.h.

◆ TInlineValue() [2/5]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
template<typename T , typename = typename TEnableIf<TPointerIsConvertibleFromTo<typename TDecay<T>::Type, BaseType>::Value>::Type>
TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::TInlineValue ( T && In)
inline

Construction from any type relating to BaseType.

Definition at line 39 of file InlineValue.h.

◆ TInlineValue() [3/5]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
template<typename... ArgTypes>
TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::TInlineValue ( EInPlace ,
ArgTypes &&... Args )
inline

In-place construction of BaseType from a set of arguments.

Definition at line 49 of file InlineValue.h.

◆ ~TInlineValue()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::~TInlineValue ( )
inline

Destructor

Definition at line 58 of file InlineValue.h.

◆ TInlineValue() [4/5]

Move construction/assignment

Definition at line 66 of file InlineValue.h.

◆ TInlineValue() [5/5]

Copy construction/assignment is disabled

Member Function Documentation

◆ ConditionallyAllocateObject()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::ConditionallyAllocateObject ( uint32 Size,
uint32 Alignment )
inlineprivate

Definition at line 209 of file InlineValue.h.

◆ ConditionallyDestroyAllocation()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::ConditionallyDestroyAllocation ( )
inlineprivate

Definition at line 219 of file InlineValue.h.

◆ Emplace()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
template<typename T , typename... ArgsType>
FORCEINLINE void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Emplace ( ArgsType &&... Args)
inline

Emplace a new type (deriving from BaseType) into this inline value

Definition at line 130 of file InlineValue.h.

◆ Get()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE const BaseType & TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Get ( const BaseType & Default) const
inline

Get the wrapped object, or a user-specified default

Returns
The object, or the user-specified default

Definition at line 159 of file InlineValue.h.

◆ GetPtr()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE BaseType * TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::GetPtr ( BaseType * Default = nullptr) const
inline

Get a pointer the wrapped object, or a user-specified default

Returns
A pointer to the object, or the user-specified default

Definition at line 168 of file InlineValue.h.

◆ GetValue()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE BaseType & TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::GetValue ( ) const
inline

Access the wrapped object's base type

Returns
A reference to the object. Will assert where IsValid() is false.

Definition at line 149 of file InlineValue.h.

◆ InitializeFrom()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
template<typename T , typename... ArgsType>
void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::InitializeFrom ( ArgsType &&... Args)
inlineprivate

Definition at line 195 of file InlineValue.h.

◆ IsValid()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE bool TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::IsValid ( ) const
inline

Check if this container is wrapping a valid object

Definition at line 140 of file InlineValue.h.

◆ operator*()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE BaseType & TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::operator* ( ) const
inline

Definition at line 173 of file InlineValue.h.

◆ operator->()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
FORCEINLINE BaseType * TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::operator-> ( ) const
inline

Definition at line 174 of file InlineValue.h.

◆ operator=() [1/3]

◆ operator=() [2/3]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
template<typename T >
TEnableIf< TPointerIsConvertibleFromTo< typenameTDecay< T >::Type, BaseType >::Value, TInlineValue & >::Type TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::operator= ( T && In)
inline

Move assignment from any type relating to BaseType.

Definition at line 87 of file InlineValue.h.

◆ operator=() [3/3]

Definition at line 71 of file InlineValue.h.

◆ Reserve()

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
void * TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Reserve ( uint32 InSize,
uint32 InAlignment )
inline

Reserve space for a structure derived from BaseType, of the size and alignment specified .

Note
Does not initialize the memory in anyway

Definition at line 180 of file InlineValue.h.

◆ Reset() [1/2]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Reset ( )
inline

Reset this container back to its empty state

Definition at line 114 of file InlineValue.h.

◆ Reset() [2/2]

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
void TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Reset ( TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment > && In)
inline

Reset this container to wrap a new type

Definition at line 96 of file InlineValue.h.

Member Data Documentation

◆ bInline

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
bool TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::bInline
private

true where InlineBytes points to a valid BaseType&, false if it's a heap allocated BaseType*

Definition at line 238 of file InlineValue.h.

◆ bIsValid

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
bool TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::bIsValid
private

true where this container is wrapping a valid object

Definition at line 235 of file InlineValue.h.

◆ Data

template<typename BaseType , uint8 DesiredMaxInlineSize = 64, uint8 DefaultAlignment = 8>
TAlignedBytes<MaxInlineSize, DefaultAlignment> TInlineValue< BaseType, DesiredMaxInlineSize, DefaultAlignment >::Data
private

Type-erased bytes containing either a BaseType& or heap allocated BaseType*

Definition at line 232 of file InlineValue.h.


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