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-2024 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:
27 explicit Finally(std::function<void()> functionToCall);
28
30 Finally(Finally&&) noexcept;
31
33 Finally& operator=(Finally&&) noexcept;
34
35 Finally(const Finally&) = delete;
36 Finally& operator=(const Finally&) = delete;
37
40
41private:
42 std::function<void()> functionToCall;
43};
44
45} // 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