JUCE API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::ScopeGuard< Fn > Struct Template Reference

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

Inherits Fn.

Public Member Functions

 ~ScopeGuard ()
 

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!
Helper class for using linear interpolation between a begin and an end value.
Definition juce_StaticAnimationLimits.h:74
An easy way to ensure that a function is called at the end of the current scope.
Definition juce_ScopeGuard.h:64

Constructor & Destructor Documentation

◆ ~ScopeGuard()

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

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