deal.II version GIT relicensing-2167-g9622207b8f 2024-11-21 12:40:00+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: 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// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_scope_exit_h
16#define dealii_scope_exit_h
17
18#include <deal.II/base/config.h>
19
20#include <functional>
21
22
24
134{
135public:
140 explicit ScopeExit(const std::function<void()> &exit_function);
141
146 ScopeExit(const ScopeExit &) = delete;
147
151 ~ScopeExit();
152
157 ScopeExit &
158 operator=(const ScopeExit &) = delete;
159
160private:
164 const std::function<void()> exit_function;
165};
166
167
168
169inline ScopeExit::ScopeExit(const std::function<void()> &exit_function)
170 : exit_function(exit_function)
171{}
172
173
174
176{
177 // Actually trigger the stored function
179}
180
181
183
184#endif
ScopeExit(const ScopeExit &)=delete
const std::function< void()> exit_function
Definition scope_exit.h:164
ScopeExit & operator=(const ScopeExit &)=delete
ScopeExit(const std::function< void()> &exit_function)
Definition scope_exit.h:169
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499