JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Finally.hpp
Go to the documentation of this file.
1// Copyright 2007-2021 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include <functional>
8
9namespace jngl {
10
22class Finally {
23public:
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
38
39private:
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: Achievement.hpp:10