OpenShot Audio Library | OpenShotAudio 0.4.0
 
Loading...
Searching...
No Matches
juce::ScopeGuard< Fn > Struct Template Reference

#include <juce_ScopeGuard.h>

Detailed Description

template<typename Fn>
struct juce::ScopeGuard< Fn >

An easy way to ensure that a function is called at the end of the current scope.

Usage:

{
if (flag == true)
return;
// While this code executes, flag is true e.g. to prevent reentrancy
flag = true;
// When we exit this scope, flag must be false
const ScopeGuard scope { [&] { flag = false; } };
if (checkInitialCondition())
return; // Scope's lambda will fire here...
if (checkCriticalCondition())
throw std::runtime_error{}; // ...or here...
doWorkHavingEstablishedPreconditions();
} // ...or here!

Definition at line 52 of file juce_ScopeGuard.h.

Constructor & Destructor Documentation

◆ ~ScopeGuard()

template<typename Fn>
juce::ScopeGuard< Fn >::~ScopeGuard ( )
inline

Definition at line 52 of file juce_ScopeGuard.h.


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