JNGL
Finally.hpp
Go to the documentation of this file.
1 // Copyright 2007-2021 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include <functional>
8 
9 namespace jngl {
10 
22 class Finally {
23 public:
25  explicit Finally(std::function<void()> functionToCall);
26 
28  Finally(Finally&&) noexcept;
29 
31  Finally& operator=(Finally&&) noexcept;
32 
33  Finally(const Finally&) = delete;
34  Finally& operator=(const Finally&) = delete;
35 
37  ~Finally();
38 
39 private:
40  std::function<void()> functionToCall;
41 };
42 
43 } // namespace jngl
Helper class which calls a function when being destroyed.
Definition: Finally.hpp:22
Finally(Finally &&) noexcept
The moved-from Finally object will no longer call the function.
Finally(std::function< void()> functionToCall)
functionToCall will be moved into the member with the same name
JNGL's main namespace.
Definition: App.hpp:10