Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
finally.h
Go to the documentation of this file.
1#pragma once
2#include <functional>
3
4namespace hgps {
5
8template <typename F> class Finally {
9 public:
13 template <typename Func> Finally(Func &&func) : functor_(std::forward<Func>(func)) {}
14
15 Finally(const Finally &) = delete;
16 Finally(Finally &&) = delete;
17 Finally &operator=(const Finally &) = delete;
18 Finally &operator=(Finally &&) = delete;
19
22 try {
23 functor_();
24 } catch (...) {
25 }
26 }
27
28 private:
29 F functor_;
30};
31
36template <typename F> Finally<F> make_finally(F &&f) { return {std::forward<F>(f)}; }
37} // namespace hgps
Define a scoped reset state data type.
Definition finally.h:8
Finally(Func &&func)
Initialises a new instance of the Finally class.
Definition finally.h:13
Finally(const Finally &)=delete
Finally(Finally &&)=delete
~Finally()
Destroys a Finally instance.
Definition finally.h:21
Finally & operator=(Finally &&)=delete
Finally & operator=(const Finally &)=delete
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
Finally< F > make_finally(F &&f)
Makes a finally instance.
Definition finally.h:36
Global namespace.
Definition column_iterator.h:123