MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::UObjects::Init Namespace Reference

Namespaces

namespace  Detail
 

Data Structures

struct  FConstructObjectParameters
 

Concepts

concept  CUObjectInitializable
 

Functions

template<CUObject T, typename... Args>
T * NewInit (FConstructObjectParameters &&params, Args &&... args)
 
template<CFunctorObject Initializer, typename TArg = TFunction_Arg<Initializer, 0>, CUObject T = std::decay_t<TArg>>
requires std::is_lvalue_reference_v<TArg>
T * Construct (FConstructObjectParameters &&params, Initializer &&init)
 
template<CFunctorObject Initializer, typename... Args, typename TArg = TFunction_Arg<Initializer, 0>, CUObject T = std::decay_t<TArg>>
requires std::is_lvalue_reference_v<TArg>
T * ConstructInit (FConstructObjectParameters &&params, Initializer &&init, Args &&... args)
 

Function Documentation

◆ Construct()

template<CFunctorObject Initializer, typename TArg = TFunction_Arg<Initializer, 0>, CUObject T = std::decay_t<TArg>>
requires std::is_lvalue_reference_v<TArg>
T * Mcro::UObjects::Init::Construct ( FConstructObjectParameters && params,
Initializer && init )

Equivalent to Mcro::Construct::Construct but for UObjects. Usage:

using namespace Mcro::UObjects::Init;
auto myObject = Construct({}, [](UMyObject& _)
{
_.Foo = 42;
_.Bar();
// etc...
});
static_assert(std::is_same_v<decltype(myObject), UMyObject*>);

Notice how the object type is deduced from the argument of the initializer.

Template Parameters
InitializerInitializer function type
Parameters
paramsParameters for every new object
initA setup function for the newly created UObject
Returns
The new object

Definition at line 137 of file Init.h.

◆ ConstructInit()

template<CFunctorObject Initializer, typename... Args, typename TArg = TFunction_Arg<Initializer, 0>, CUObject T = std::decay_t<TArg>>
requires std::is_lvalue_reference_v<TArg>
T * Mcro::UObjects::Init::ConstructInit ( FConstructObjectParameters && params,
Initializer && init,
Args &&... args )

Equivalent to Mcro::Construct::Construct but for UObjects. If the constructed UObject type also has an Initialize function call that too after the lambda initializer. The args parameters should match the signature of Initialize in that case. Usage:

using namespace Mcro::UObjects::Init;
auto myObject = Construct({}, [](UMyObject& _)
{
_.Foo = 42;
_.Bar();
// etc...
});
static_assert(std::is_same_v<decltype(myObject), UMyObject*>);

Notice how the object type is deduced from the argument of the initializer.

Template Parameters
InitializerInitializer function type
ArgsArguments for the Initialize function
Parameters
paramsParameters for every new object
initA setup function for the newly created UObject
argsArguments for the Initialize function
Returns
The new object

Definition at line 187 of file Init.h.

◆ NewInit()

template<CUObject T, typename... Args>
T * Mcro::UObjects::Init::NewInit ( FConstructObjectParameters && params,
Args &&... args )

Create a new object which can also be initialized with an Initialize function if it has one. In case it has an Initialize function the args parameters should match them. This is an equivalent to the template Mcro::SharedObjects::MakeShareableInit

Template Parameters
TType of initializable UObject
ArgsArguments for the Initialize function
Parameters
paramsParameters for every new object
argsArguments for the Initialize function
Returns
The new object

Definition at line 92 of file Init.h.