Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
scope_exit.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_scope_exit_h
17#define dealii_scope_exit_h
18
19#include <deal.II/base/config.h>
20
21#include <functional>
22
23
25
135{
136public:
141 explicit ScopeExit(const std::function<void()> &exit_function);
142
147 ScopeExit(const ScopeExit &) = delete;
148
152 ~ScopeExit();
153
158 ScopeExit &
159 operator=(const ScopeExit &) = delete;
160
161private:
165 const std::function<void()> exit_function;
166};
167
168
169
170inline ScopeExit::ScopeExit(const std::function<void()> &exit_function)
171 : exit_function(exit_function)
172{}
173
174
175
177{
178 // Actually trigger the stored function
180}
181
182
184
185#endif
ScopeExit(const ScopeExit &)=delete
const std::function< void()> exit_function
Definition scope_exit.h:165
ScopeExit & operator=(const ScopeExit &)=delete
ScopeExit(const std::function< void()> &exit_function)
Definition scope_exit.h:170
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473