16#include "CoreMinimal.h"
59 template <
typename Self>
67 template <
typename Self>
68 using SelfRef = TSharedRef<std::decay_t<Self>>;
71 template <CSharedFromThis Self>
79 template <
typename Self>
80 requires (!CSharedFromThis<Self>)
104 template <
typename Derived, CSharedFromThis Self>
105 TSharedPtr<Derived>
As(
this Self&& self)
107 if constexpr (CDerivedFrom<Derived, Self>)
108 return StaticCastSharedPtr<Derived>(
113 if (self.TypeInfo.template IsCompatibleWith<Derived>())
114 return StaticCastSharedPtr<Derived>(
134 template <
typename Derived,
typename Self>
135 requires (!CSharedFromThis<Self>)
136 Derived*
As(
this Self&& self)
138 if constexpr (CDerivedFrom<Derived, Self>)
139 return static_cast<Derived*
>(&self);
142 if (self.TypeInfo.template IsCompatibleWith<Derived>())
143 return static_cast<Derived*
>(&self);
152 ,
public TSharedFromThis<IHaveTypeShareable>
156 template <
typename T>
159 ,
public TSharedFromThis<T>
#define FWD(...)
Shorten forwarding expression with this macro so one may not need to specify explicit type.
Shorthand for combination of IHaveType and TSharedFromThis
A barebones base class for types which may store their type-name as a string.
virtual ~IHaveType()=default
FORCEINLINE FString GetTypeString() const
FORCEINLINE FName const & GetTypeFName() const
Self && WithType(this Self &&self)
Fluent API for setting tpye for deferred initialization (for example in factory functions)
FORCEINLINE FType const & GetType() const
Derived * As(this Self &&self)
Dynamic casting of this object to a derived top-level type. Casting also works if inheritance is done...
void SetType(this Self &&self)
This function needs to be called on top level derived type for runtime reflection to work.
SelfRef< Self > WithType(this Self &&self)
Fluent API for setting tpye for deferred initialization (for example in factory functions)
TSharedRef< std::decay_t< Self > > SelfRef
TSharedPtr< Derived > As(this Self &&self)
Dynamic casting of this object to a derived top-level type. Casting also works if inheritance is done...
Shorthand for combination of IHaveType and TSharedFromThis where the base-type can be specified.
Utilities for TSharedPtr/Ref and related.
auto SharedSelf(const T *self) -> TSharedRef< T const, Mode >
Same as SharedThis(this) in TSharedFromThis.
This namespace provides templating utilities and introspection into template instantiations.
constexpr auto AsMutablePtr(T *input)
Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
FName TTypeFName()
Same as TTypeName converted to FName. This is not cached and a new FName is created every time this i...
C++ native static reflection utilities, not to be confused with reflection of UObjects.
Group together type info for identification. Can have an invalid state when no type is specified.