JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::ErasedScopeGuard Class Reference

A ScopeGuard that uses a std::function internally to allow type erasure. More...

#include "juce_ScopeGuard.h"

Public Member Functions

 ErasedScopeGuard ()=default
 Constructs an ErasedScopeGuard with no callback.
 
 ErasedScopeGuard (std::function< void()> d)
 Constructs an ErasedScopeGuard that will call the provided callback when the Guard is destroyed.
 
 ErasedScopeGuard (ErasedScopeGuard &&other) noexcept
 Constructs an instance that assumes responsibility for calling other's callback.
 
ErasedScopeGuardoperator= (ErasedScopeGuard &&other) noexcept
 Calls the stored callback, if any, then assumes responsibility for calling other's callback.
 
 ~ErasedScopeGuard () noexcept
 Destructor, calls the callback assigned to this ScopeGuard.
 
void reset ()
 Calls the stored callback, if any, then resets this instance to its default state.
 
void release ()
 Resets this instance to its default state without calling the stored callback.
 

Detailed Description

A ScopeGuard that uses a std::function internally to allow type erasure.

This can be handy; it allows lots of ErasedScopeGuards, all with different callbacks, to be stored in a homogeneous container.

An instance of this type will automatically call its callback when it is destroyed.

ErasedScopeGuard has a few similarities with std::unique_ptr:

@tags{Core}

Definition at line 76 of file juce_ScopeGuard.h.

Constructor & Destructor Documentation

◆ ErasedScopeGuard() [1/2]

juce::ErasedScopeGuard::ErasedScopeGuard ( std::function< void()>  d)
explicit

Constructs an ErasedScopeGuard that will call the provided callback when the Guard is destroyed.

Definition at line 26 of file juce_ScopeGuard.cpp.

◆ ErasedScopeGuard() [2/2]

juce::ErasedScopeGuard::ErasedScopeGuard ( ErasedScopeGuard &&  other)
noexcept

Constructs an instance that assumes responsibility for calling other's callback.

Definition at line 29 of file juce_ScopeGuard.cpp.

◆ ~ErasedScopeGuard()

juce::ErasedScopeGuard::~ErasedScopeGuard ( )
noexcept

Destructor, calls the callback assigned to this ScopeGuard.

Definition at line 39 of file juce_ScopeGuard.cpp.

Member Function Documentation

◆ operator=()

ErasedScopeGuard & juce::ErasedScopeGuard::operator= ( ErasedScopeGuard &&  other)
noexcept

Calls the stored callback, if any, then assumes responsibility for calling other's callback.

After this call, other will be reset to its default state.

Definition at line 32 of file juce_ScopeGuard.cpp.

◆ release()

void juce::ErasedScopeGuard::release ( )

Resets this instance to its default state without calling the stored callback.

Definition at line 50 of file juce_ScopeGuard.cpp.

◆ reset()

void juce::ErasedScopeGuard::reset ( )

Calls the stored callback, if any, then resets this instance to its default state.

Definition at line 44 of file juce_ScopeGuard.cpp.


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