UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NonNullSubclassOf.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/Class.h"
7#include "UObject/Field.h"
8#include "SubclassOf.h"
10
11// So we can construct uninitialized TNonNullSubclassOf
13
17template <typename T>
19{
20 using Super = TSubclassOf<T>;
21
22public:
28
30 template <
31 typename PtrType
32 UE_REQUIRES(std::is_same_v<PtrType, UClass> || std::is_same_v<PtrType, FFieldClass>)>
33 [[nodiscard]] inline TNonNullSubclassOf(PtrType* From)
34 : Super(From)
35 {
36 checkf(From, TEXT("Initializing TNonNullSubclassOf with null"));
37 }
38
40 template <
41 typename U
42 UE_REQUIRES(std::is_convertible_v<U*, T*>)
43 >
48
50 template
51 <
52 typename U
53 UE_REQUIRES(std::is_convertible_v<U*, T*>)
54 >
56 {
57 checkf(*From, TEXT("Assigning null to TNonNullSubclassOf"));
58 Super::operator=(From);
59 return *this;
60 }
61
63 template <typename PtrType>
64 inline TNonNullSubclassOf& operator=(PtrType* From)
65 {
66 checkf(From, TEXT("Assigning null to TNonNullSubclassOf"));
67 Super::operator=(From);
68 return *this;
69 }
70
72 // Start - intrusive TOptional<TNonNullSubclassOf> state //
74 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
80
82 {
83 return Super::Get() == nullptr;
84 }
86 // End - intrusive TOptional<TNonNullSubclassOf> state //
88};
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EDefaultConstructNonNullSubclassOf
Definition NonNullSubclassOf.h:12
#define UE_REQUIRES(...)
Definition Requires.h:86
Definition NonNullSubclassOf.h:19
UE_FORCEINLINE_HINT bool operator==(FIntrusiveUnsetOptionalState) const
Definition NonNullSubclassOf.h:81
UE_FORCEINLINE_HINT TNonNullSubclassOf(FIntrusiveUnsetOptionalState)
Definition NonNullSubclassOf.h:76
static constexpr bool bHasIntrusiveUnsetOptionalState
Definition NonNullSubclassOf.h:74
TNonNullSubclassOf & operator=(PtrType *From)
Definition NonNullSubclassOf.h:64
UE_FORCEINLINE_HINT TNonNullSubclassOf(const TSubclassOf< U > &From)
Definition NonNullSubclassOf.h:44
TNonNullSubclassOf(PtrType *From)
Definition NonNullSubclassOf.h:33
UE_FORCEINLINE_HINT TNonNullSubclassOf(EDefaultConstructNonNullSubclassOf)
Definition NonNullSubclassOf.h:24
TNonNullSubclassOf & operator=(const TSubclassOf< U > &From)
Definition NonNullSubclassOf.h:55
Definition SubclassOf.h:30
TSubclassOf & operator=(TSubclassOf &&)=default
UE_FORCEINLINE_HINT UClass * Get() const
Definition SubclassOf.h:119
Definition IntrusiveUnsetOptionalState.h:71