UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GSLNotNull.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Misc/OptionalFwd.h"
8#include <gsl/pointers>
9
10class FArchive;
11
13template<typename ObjectType>
14[[nodiscard]] inline ObjectType* GetRawPointerOrNull(const TOptional<gsl::not_null<ObjectType*>>& Optional)
15{
16 return Optional.IsSet() ? static_cast<ObjectType*>(Optional.GetValue()) : nullptr;
17}
18
20template<typename ObjectType>
21[[nodiscard]] inline ObjectType* GetRawPointerOrNull(const TOptional<gsl::strict_not_null<ObjectType*>>& Optional)
22{
23 return Optional.IsSet() ? static_cast<ObjectType*>(Optional.GetValue()) : nullptr;
24}
25
26
28template<typename ObjectType>
29FArchive& operator<<(FArchive& Ar, gsl::not_null<ObjectType>& NotNull)
30{
31 Ar << *NotNull;
32 return Ar;
33}
34
36template<typename ObjectType>
37FArchive& operator<<(FArchive& Ar, gsl::strict_not_null<ObjectType>& NotNull)
38{
39 Ar << *NotNull;
40 return Ar;
41}
42
44template<typename ObjectType>
45[[nodiscard]] inline auto GetTypeHash(const gsl::not_null<ObjectType>& NotNull) -> decltype(GetTypeHash(*NotNull))
46{
47 return GetTypeHash(*NotNull);
48}
49
51template<typename ObjectType>
52[[nodiscard]] inline auto GetTypeHash(const gsl::strict_not_null<ObjectType>& NotNull) -> decltype(GetTypeHash(*NotNull))
53{
54 return GetTypeHash(*NotNull);
55}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
auto GetTypeHash(const gsl::not_null< ObjectType > &NotNull) -> decltype(GetTypeHash(*NotNull))
Definition GSLNotNull.h:45
ObjectType * GetRawPointerOrNull(const TOptional< gsl::not_null< ObjectType * > > &Optional)
Definition GSLNotNull.h:14
FArchive & operator<<(FArchive &Ar, gsl::not_null< ObjectType > &NotNull)
Definition GSLNotNull.h:29
Definition Archive.h:1208
Definition Optional.h:131