MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
SharedObjects.h File Reference
#include "CoreMinimal.h"
#include "Mcro/FunctionTraits.h"
#include "Mcro/Construct.h"

Go to the source code of this file.

Data Structures

struct  Mcro::SharedObjects::TSharedStorage< T >
 A simple mutable shared storage of any value. More...
 

Namespaces

namespace  Mcro
 
namespace  Mcro::SharedObjects
 Utilities for TSharedPtr/Ref and related.
 

Concepts

concept  Mcro::SharedObjects::CSharedInitializeable
 Concept describing an object which provides a deferred initializer for shared objects.
 

Typedefs

template<CSharedOrWeak T>
using Mcro::SharedObjects::TSharedPtrFrom = TSharedPtr<typename T::ElementType, T::Mode>
 Copy thread-safety from other shared object type.
 
template<CSharedOrWeak T>
using Mcro::SharedObjects::TSharedRefFrom = TSharedRef<typename T::ElementType, T::Mode>
 Copy thread-safety from other shared object type.
 
template<CSharedOrWeak T>
using Mcro::SharedObjects::TWeakPtrFrom = TWeakPtr<typename T::ElementType, T::Mode>
 Copy thread-safety from other shared object type.
 
template<CDefaultInitializable T>
using Mcro::SharedObjects::TSharedStoragePtr = TSharedPtr<TSharedStorage<T>>
 
template<CDefaultInitializable T>
using Mcro::SharedObjects::TSharedStorageRef = TSharedRef<TSharedStorage<T>>
 
template<CDefaultInitializable T>
using Mcro::SharedObjects::TSharedStorageWeakPtr = TWeakPtr<TSharedStorage<T>>
 

Functions

template<typename T , ESPMode Mode = ESPMode::ThreadSafe, typename... Args>
requires CSharedInitializeable<T, Args...>
TSharedRef< T, Mode > Mcro::SharedObjects::MakeShareableInit (T *newObject, Args &&... args)
 A wrapper around MakeShareable that automatically calls an initializer method Initialize on the instantiated object.
 
template<CFunctorObject Initializer, typename... Args, ESPMode Mode = ESPMode::ThreadSafe, typename ResultArg = TFunction_Arg<Initializer, 0>, typename Result = std::decay_t<ResultArg>>
requires std::is_lvalue_reference_v<ResultArg>
TSharedRef< Result, Mode > Mcro::SharedObjects::ConstructShared (Initializer &&init, Args &&... args)
 A combination of MakeShareable and Mcro::Construct::ConstructNew.
 
template<CRefCounted T, ESPMode Mode = ESPMode::ThreadSafe>
TSharedRef< T, Mode > Mcro::SharedObjects::ShareRefCounted (T *object)
 Create a shared pointer which takes in an object with in-place refcounting.
 
template<CSharedFromThis T, ESPMode Mode = decltype(DeclVal<T const>().AsShared())::Mode>
auto Mcro::SharedObjects::WeakSelf (const T *self) -> TWeakPtr< T const, Mode >
 Same as SharedThis(this) in TSharedFromThis but returning a weak pointer instead.
 
template<CSharedFromThis T, ESPMode Mode = decltype(DeclVal<T>().AsShared())::Mode>
auto Mcro::SharedObjects::WeakSelf (T *self) -> TWeakPtr< T, Mode >
 Same as SharedThis(this) in TSharedFromThis but returning a weak pointer instead.
 
FORCEINLINE TSharedStorageRef< FDelegateHandle > Mcro::SharedObjects::MakeSharedDelegateHandle ()
 A simple convenience wrapper around making FDelegateHandles shared.
 

Detailed Description

Author
David Mórász
Date
2025

Definition in file SharedObjects.h.