Go to the source code of this file.
◆ UE_ENABLE_NOTNULL_WRAPPER
TNotNull is a wrapper template which is used to indicate that a pointer or handle is never intended to be null.
Design and rationale:
- No default construction, construction with nullptr or comparison against nullptr. Attempting to do so will cause a compile error.
- While intended for pointer types, it should be usable for anything else that is nullable, e.g. TFunction.
- The pointer value is checked on construction or assignment, and then never after that. The only exception to this is a TNotNull in a moved-from state, which will not re-check the value. - see below.
- TNotNull is movable. This allows things like TNotNull<TUniquePtr<T>> to be expressed, but means that a moved-from TNotNull variable can end up being null. However, users are never required to handle a variable in this state. If a variable is to be reused after it has been moved from (e.g. a data member of an object that isn't being destroyed) then code that made it null should assign a new non-null value to it before returning to user code or using it to construct or assign to another TNotNull. Users of your variable should never be allowed to see a null value. Compilers and static analyzers are allowed to assume that the pointer is not null and optimize and analyze accordingly.
- The UE_ENABLE_NOTNULL_WRAPPER can be used to disable all checking and become an alias to the inner type, so there is no runtime overhead at all.
◆ UE_NOTNULL_FUNCTION_NON_NULL_RETURN_END
◆ UE_NOTNULL_FUNCTION_NON_NULL_RETURN_START
◆ TNotNull
◆ NotNullGet()
| T && NotNullGet |
( |
T && |
NotNull | ) |
|