Template to allow TClassType's to be passed around with type safety.
More...
#include <SubClassOf.h>
|
|
typedef TChooseClass< TIsDerivedFrom< TClass, FField >::IsDerived, FFieldClass, UClass >::Result | TClassType |
| | Since I don't think I understand the purpose of this typedef, I may attempt to parse the code. Seems like if TClass is derived from FField then TClassType is FFieldClass, else, UClass (for most scenarios). The pointer variable is of this type, i.e TClassType.
|
|
typedef TChooseClass< TIsDerivedFrom< TClass, FField >::IsDerived, FField, UObject >::Result | TBaseType |
| | Again, on parsing, I understand the meaning to be, if TClass is derived from FField then TBaseType is FField else UObject (for most scenarios). The return type of GetDefaultObject() is of this type, again UObject for majority of the cases.
|
template<class TClass>
class Karma::TSubclassOf< TClass >
Template to allow TClassType's to be passed around with type safety.
◆ TSubclassOf() [1/4]
Default Constructor, defaults to null
- Since
- Karma 1.0.0
◆ TSubclassOf() [2/4]
Constructor that takes a UClass and does a runtime check to make sure this is a compatible class
- Parameters
-
- Since
- Karma 1.0.0
◆ TSubclassOf() [3/4]
template<class TClass>
template<typename U, std::enable_if_t<!
TIsTSubclassOf< std::decay_t< U > >::Value, decltype(ImplicitConv<
TClassType * >(std::declval< U >())) > * = nullptr>
Constructor that takes a UClass and does a runtime check to make sure this is a compatible class.
Understanding by-parts
- std::decay_t: allowing the "pass by reference" of parameter (https://stackoverflow.com/a/25732651). Basically an equivalence is established between, for instance, int(&)[2] and int* (reference to an array, even whole array, and pointer to appropriate data type)
std::declval: Converts any type U to a reference type, allowing the use of class (struct) functions of U without actually initializing an object (simillar to that of static functions, in the sense no object is needed). For instance:
struct NonDefault
{
NonDefault() = delete;
int foo() const { return 1; }
};
decltype(Default().foo()) n1 = 1;
Note the usage of foo() function without creating the object
- ImplicitConv<TClassType*>: An Unreal Engine function, uses implicit conversion to create an instance of a specific type. Not functional here yet
- decltype: The decltype keyword inspects the declared type of an entity or the type of an expression. ‘auto’ lets you declare a variable with a particular type whereas decltype lets you extract the type from the variable so decltype is sort of an operator that evaluates the type of passed expression.
std::enable_if_t: Consider the following statement
template< bool B, class T = void >
struct enable_if;
then, If B is true, std::enable_if has a public member typedef type, equal to T; otherwise, there is no member typedef.
template< bool B, class T = void >
using enable_if_t = typename enable_if<B,T>::type;
- Parameters
-
| From | A (mostly) UClass pointer with runtime check (which I don't practically understand) |
- Todo
- Definition for ImplicitConv needs to be provided
- Since
- Karma 1.0.0
◆ TSubclassOf() [4/4]
template<class TClass>
template<class TClassA, class = decltype(ImplicitConv<TClass*>((TClassA*)nullptr))>
Copy Constructor, will only compile if types are compatible
- Parameters
-
- Since
- Karma 1.0.0
◆ Get()
Dereference back into a UClass
- Since
- Karma 1.0.0
◆ GetDefaultObject()
Get the CDO if we are referencing a valid class
- Returns
- the CDO, or null if class is null
- Since
- Karma 1.0.0
◆ operator TClassType *()
Implicit conversion to UClass
- Since
- Karma 1.0.0
◆ operator*()
Dereference back into a UClass, does runtime type checking
- Note
- Not seen practical example
- Since
- Karma 1.0.0
◆ operator->()
Dereference back into a UClass
- Since
- Karma 1.0.0
◆ operator=() [1/3]
template<class TClass>
template<class TClassA, class = decltype(ImplicitConv<TClass*>((TClassA*)nullptr))>
| TSubclassOf & Karma::TSubclassOf< TClass >::operator= |
( |
const TSubclassOf< TClassA > & | From | ) |
|
|
inline |
Assignment operator, will only compile if types are compatible
- Parameters
-
| From | The object to copy from |
- Since
- Karma 1.0.0
◆ operator=() [2/3]
Assignment operator from UClass, the type is checked on get not on set
- Parameters
-
| From | The object to copy from |
- Since
- Karma 1.0.0
◆ operator=() [3/3]
template<class TClass>
template<typename U, std::enable_if_t< !
TIsTSubclassOf< std::decay_t< U > >::Value, decltype(ImplicitConv<
TClassType * >(std::declval< U >())) > * = nullptr>
Assignment operator from UClass, the type is checked on get not on set
- Parameters
-
- Since
- Karma 1.0.0
The documentation for this class was generated from the following file: