![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
Go to the source code of this file.
Classes | |
| class | ScopeExitSupport::TScopeGuard< FuncType > |
| struct | ScopeExitSupport::FScopeGuardSyntaxSupport |
Namespaces | |
| namespace | ScopeExitSupport |
Macros | |
| #define | UE_PRIVATE_SCOPE_EXIT_JOIN(A, B) UE_PRIVATE_SCOPE_EXIT_JOIN_INNER(A, B) |
| #define | UE_PRIVATE_SCOPE_EXIT_JOIN_INNER(A, B) A##B |
| #define | ON_SCOPE_EXIT const auto UE_PRIVATE_SCOPE_EXIT_JOIN(ScopeGuard_, __LINE__) = ::ScopeExitSupport::FScopeGuardSyntaxSupport() + [&]() |
| #define ON_SCOPE_EXIT const auto UE_PRIVATE_SCOPE_EXIT_JOIN(ScopeGuard_, __LINE__) = ::ScopeExitSupport::FScopeGuardSyntaxSupport() + [&]() |
Enables a lambda to be executed on scope exit.
Example: { FileHandle* Handle = GetFileHandle(); ON_SCOPE_EXIT { CloseFile(Handle); };
DoSomethingWithFile( Handle );
// File will be closed automatically no matter how the scope is exited, e.g.: // * Any return statement. // * break or continue (if the scope is a loop body). // * An exception is thrown outside the block. // * Execution reaches the end of the block. }