E-MailRelay

Public Member Functions | List of all members
G::ScopeExit Class Reference

A class that calls an exit function at the end of its scope. More...

`#include <gscope.h>`

## Public Member Functions
| ScopeExit (std::function< void()> fn)
| Constructor. More...
| ~ScopeExit ()
| Destructor. More...
void | release () noexcept
| Deactivates the exit function. More...
| ScopeExit (const ScopeExit &)=delete
| ScopeExit (ScopeExit &&)=delete
void | operator= (const ScopeExit &)=delete
void | operator= (ScopeExit &&)=delete

## Detailed Description

A class that calls an exit function at the end of its scope.

Eg:

{
int fd = open( ... ) ;
ScopeExit closer( [&](){close(fd);} ) ;
int nread = read( fd , ... ) ;
}
G::ScopeExit::ScopeExit
ScopeExit(std::function< void()> fn)
Constructor.
Definition: gscope.h:99

Definition at line 45 of file gscope.h.

## Constructor & Destructor Documentation

## ◆ ScopeExit()

G::ScopeExit::ScopeExit | ( | std::function< void()> | fn | ) |
| inline explicit

Constructor.

Definition at line 99 of file gscope.h.

## ◆ ~ScopeExit()

G::ScopeExit::~ScopeExit | ( |  | ) |
| inline

Destructor.

Calls the exit function unless release()d.

Definition at line 111 of file gscope.h.

## Member Function Documentation

## ◆ release()

void G::ScopeExit::release | ( |  | ) |
| inline noexcept

Deactivates the exit function.

Definition at line 105 of file gscope.h.

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

- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/glib/gscope.h