userver: utils::FastScopeGuard< Callback > Class Template Reference
Loading...
Searching...
No Matches
utils::FastScopeGuard< Callback > Class Template Referencefinal

#include <userver/utils/fast_scope_guard.hpp>

Detailed Description

template<typename Callback>
class utils::FastScopeGuard< Callback >

a helper class to perform actions on scope exit

The lambda argument must be explicitly marked as noexcept. Only use FastScopeGuard if it's proven that the lambda body is noexcept, otherwise use ScopeGuard.

Usage example:

int x = 0;
{
utils::FastScopeGuard d([&]() noexcept { x = 1; });
EXPECT_EQ(x, 0);
}
EXPECT_EQ(x, 1);
See also
ScopeGuard for type-erasure and throwing functor support
Examples
samples/tcp_full_duplex_service/tcp_full_duplex_service.cpp.

Definition at line 26 of file fast_scope_guard.hpp.

Public Member Functions

constexpr FastScopeGuard (Callback callback) noexcept
 
constexpr FastScopeGuard (FastScopeGuard &&other) noexcept
 
constexpr FastScopeGuardoperator= (FastScopeGuard &&other) noexcept
 
constexpr void Release () noexcept
 

Constructor & Destructor Documentation

◆ FastScopeGuard() [1/2]

template<typename Callback >
constexpr utils::FastScopeGuard< Callback >::FastScopeGuard ( Callback callback)
inlineexplicitconstexprnoexcept

Definition at line 36 of file fast_scope_guard.hpp.

◆ FastScopeGuard() [2/2]

template<typename Callback >
constexpr utils::FastScopeGuard< Callback >::FastScopeGuard ( FastScopeGuard< Callback > && other)
inlineconstexprnoexcept

Definition at line 39 of file fast_scope_guard.hpp.

◆ ~FastScopeGuard()

template<typename Callback >
utils::FastScopeGuard< Callback >::~FastScopeGuard ( )
inline

Definition at line 51 of file fast_scope_guard.hpp.

Member Function Documentation

◆ operator=()

template<typename Callback >
constexpr FastScopeGuard & utils::FastScopeGuard< Callback >::operator= ( FastScopeGuard< Callback > && other)
inlineconstexprnoexcept

Definition at line 43 of file fast_scope_guard.hpp.

◆ Release()

template<typename Callback >
constexpr void utils::FastScopeGuard< Callback >::Release ( )
inlineconstexprnoexcept

Definition at line 55 of file fast_scope_guard.hpp.


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