MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::ValueThunk::TValueThunk< T > Struct Template Reference

Either a singular value of T, or a function returning T. It's very similar to TAttribute, however it doesn't rely on delegates, and has implicit conversions. TValueThunk owns its wrapped value. More...

#include <ValueThunk.h>

Public Types

using FunctionStorage = std::conditional_t<CCopyConstructible<T>, TFunction<T()>, TUniqueFunction<T()>>
 

Public Member Functions

template<CDefaultInitializable = T>
 TValueThunk ()
 
template<CCopyConstructible = T>
 TValueThunk (T const &value)
 
template<CConvertibleTo< T > Other, CCopyConstructible = T>
 TValueThunk (TValueThunk< Other > const &other)
 
template<CMoveConstructible = T>
 TValueThunk (T &&value)
 
template<CMoveConstructible = T>
 TValueThunk (TValueThunk &&other)
 
template<CFunctorObject Functor>
requires CConvertibleTo<TFunction_ReturnDecay<Functor>, T>
 TValueThunk (Functor &&value, FValueThunkOptions const &options={})
 
T & Get ()
 Evaluate the optional functor and get the cached result.
 
T const & Get () const
 Evaluate the optional functor and get the cached result.
 
T && Steal () &&
 Evaluate the optional functor and move the cached result.
 
T & GetLast ()
 Get a cached/last result without calling the optional functor.
 
T const & GetLast () const
 Get a cached/last result without calling the optional functor.
 
T && StealLast () &&
 Move a cached/last result without calling the optional functor.
 
 operator T& ()
 
 operator T const & () const
 
 operator T&& () &&
 
bool IsSet () const
 
template<CFunctorObject Functor>
requires CConvertibleTo<TFunction_ReturnDecay<Functor>, T>
TValueThunkoperator= (Functor &&value)
 
template<CConvertibleTo< T > Other>
requires (!CIsTemplate<Other, TValueThunk>)
TValueThunkoperator= (Other &&value)
 

Friends

template<typename Other >
struct TValueThunk
 

Detailed Description

template<typename T>
struct Mcro::ValueThunk::TValueThunk< T >

Either a singular value of T, or a function returning T. It's very similar to TAttribute, however it doesn't rely on delegates, and has implicit conversions. TValueThunk owns its wrapped value.

Definition at line 41 of file ValueThunk.h.

Member Typedef Documentation

◆ FunctionStorage

template<typename T >
using Mcro::ValueThunk::TValueThunk< T >::FunctionStorage = std::conditional_t<CCopyConstructible<T>, TFunction<T()>, TUniqueFunction<T()>>

Definition at line 46 of file ValueThunk.h.

Constructor & Destructor Documentation

◆ TValueThunk() [1/6]

template<typename T >
template<CDefaultInitializable = T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( )
inline

Definition at line 49 of file ValueThunk.h.

◆ TValueThunk() [2/6]

template<typename T >
template<CCopyConstructible = T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( T const & value)
inline

Definition at line 52 of file ValueThunk.h.

◆ TValueThunk() [3/6]

template<typename T >
template<CConvertibleTo< T > Other, CCopyConstructible = T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( TValueThunk< Other > const & other)
inline

Definition at line 55 of file ValueThunk.h.

◆ TValueThunk() [4/6]

template<typename T >
template<CMoveConstructible = T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( T && value)
inline

Definition at line 64 of file ValueThunk.h.

◆ TValueThunk() [5/6]

template<typename T >
template<CMoveConstructible = T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( TValueThunk< T > && other)
inline

Definition at line 67 of file ValueThunk.h.

◆ TValueThunk() [6/6]

template<typename T >
template<CFunctorObject Functor>
requires CConvertibleTo<TFunction_ReturnDecay<Functor>, T>
Mcro::ValueThunk::TValueThunk< T >::TValueThunk ( Functor && value,
FValueThunkOptions const & options = {} )
inline

Definition at line 77 of file ValueThunk.h.

Member Function Documentation

◆ Get() [1/2]

template<typename T >
T & Mcro::ValueThunk::TValueThunk< T >::Get ( )
inline

Evaluate the optional functor and get the cached result.

Definition at line 94 of file ValueThunk.h.

◆ Get() [2/2]

template<typename T >
T const & Mcro::ValueThunk::TValueThunk< T >::Get ( ) const
inline

Evaluate the optional functor and get the cached result.

Definition at line 97 of file ValueThunk.h.

◆ GetLast() [1/2]

template<typename T >
T & Mcro::ValueThunk::TValueThunk< T >::GetLast ( )
inline

Get a cached/last result without calling the optional functor.

Definition at line 103 of file ValueThunk.h.

◆ GetLast() [2/2]

template<typename T >
T const & Mcro::ValueThunk::TValueThunk< T >::GetLast ( ) const
inline

Get a cached/last result without calling the optional functor.

Definition at line 106 of file ValueThunk.h.

◆ IsSet()

template<typename T >
bool Mcro::ValueThunk::TValueThunk< T >::IsSet ( ) const
inline

Definition at line 115 of file ValueThunk.h.

◆ operator T const &()

template<typename T >
Mcro::ValueThunk::TValueThunk< T >::operator T const & ( ) const
inline

Definition at line 112 of file ValueThunk.h.

◆ operator T&()

template<typename T >
Mcro::ValueThunk::TValueThunk< T >::operator T& ( )
inline

Definition at line 111 of file ValueThunk.h.

◆ operator T&&()

template<typename T >
Mcro::ValueThunk::TValueThunk< T >::operator T&& ( ) &&
inline

Definition at line 113 of file ValueThunk.h.

◆ operator=() [1/2]

template<typename T >
template<CFunctorObject Functor>
requires CConvertibleTo<TFunction_ReturnDecay<Functor>, T>
TValueThunk & Mcro::ValueThunk::TValueThunk< T >::operator= ( Functor && value)
inline

Definition at line 119 of file ValueThunk.h.

◆ operator=() [2/2]

template<typename T >
template<CConvertibleTo< T > Other>
requires (!CIsTemplate<Other, TValueThunk>)
TValueThunk & Mcro::ValueThunk::TValueThunk< T >::operator= ( Other && value)
inline

Definition at line 128 of file ValueThunk.h.

◆ Steal()

template<typename T >
T && Mcro::ValueThunk::TValueThunk< T >::Steal ( ) &&
inline

Evaluate the optional functor and move the cached result.

Definition at line 100 of file ValueThunk.h.

◆ StealLast()

template<typename T >
T && Mcro::ValueThunk::TValueThunk< T >::StealLast ( ) &&
inline

Move a cached/last result without calling the optional functor.

Definition at line 109 of file ValueThunk.h.

Friends And Related Symbol Documentation

◆ TValueThunk

template<typename T >
template<typename Other >
friend struct TValueThunk
friend

Definition at line 44 of file ValueThunk.h.


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