deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\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// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_scope_exit_h
14#define dealii_scope_exit_h
15
16#include <deal.II/base/config.h>
17
18#include <functional>
19
20
22
132{
133public:
138 explicit ScopeExit(const std::function<void()> &exit_function);
139
144 ScopeExit(const ScopeExit &) = delete;
145
149 ~ScopeExit();
150
155 ScopeExit &
156 operator=(const ScopeExit &) = delete;
157
158private:
162 const std::function<void()> exit_function;
163};
164
165
166
167inline ScopeExit::ScopeExit(const std::function<void()> &exit_function)
168 : exit_function(exit_function)
169{}
170
171
172
174{
175 // Actually trigger the stored function
177}
178
179
181
182#endif
ScopeExit(const ScopeExit &)=delete
const std::function< void()> exit_function
Definition scope_exit.h:162
ScopeExit & operator=(const ScopeExit &)=delete
ScopeExit(const std::function< void()> &exit_function)
Definition scope_exit.h:167
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39