ReXGlue SDK
Loading...
Searching...
No Matches
rex::ScopeGuard Class Reference

#include <rex/utility.h>

Public Member Functions

 ScopeGuard (MoveOnlyFunction< void()> release)
 ScopeGuard (ScopeGuard &&other) noexcept
ScopeGuard & operator= (ScopeGuard &&other) noexcept
void Reset ()

Detailed Description

Runs a function once when it is destroyed, reset or assigned over. Move only and nullable.

Constructor & Destructor Documentation

◆ ScopeGuard() [1/2]

rex::ScopeGuard::ScopeGuard ( MoveOnlyFunction< void()> release)
explicit

Creates a guard that runs a function.

Parameters
releaseRuns once, on destruction, Reset or reassignment.

◆ ScopeGuard() [2/2]

rex::ScopeGuard::ScopeGuard ( ScopeGuard && other)
noexcept

Takes the function of another guard.

Parameters
otherThe guard to take from, which then does nothing.

Member Function Documentation

◆ operator=()

ScopeGuard & rex::ScopeGuard::operator= ( ScopeGuard && other)
noexcept

Runs this function and takes the function of another guard.

Parameters
otherThe guard to take from, which then does nothing.

◆ Reset()

void rex::ScopeGuard::Reset ( )

Runs the function now and leaves the guard doing nothing.


The documentation for this class was generated from the following file: