HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
defer.hpp
1
// Copyright Take Vos 2022.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
6
#include "
utility.hpp
"
7
#include <type_traits>
8
#include <concepts>
9
10
#pragma once
11
12
namespace
hi::inline
v1
{
13
20
template
<std::invocable<> T>
21
class
defer
{
22
public
:
23
defer
() =
delete
;
24
defer
(
defer
&&) =
delete
;
25
defer
(
defer
const
&) =
delete
;
26
defer
&operator=(
defer
&&) =
delete
;
27
defer
&operator=(
defer
const
&) =
delete
;
28
29
template
<std::invocable<> Func>
30
[[nodiscard]]
constexpr
defer
(Func &&func) noexcept : _func(std::forward<Func>(func)) {}
31
32
constexpr
~defer
()
33
{
34
std::move
(_func)();
35
}
36
37
private
:
38
T _func;
39
};
40
41
template
<std::invocable<> Func>
42
defer
(Func &&) ->
defer<std::remove_cvref_t<Func>
>;
43
44
}
45
utility.hpp
Utilities used by the HikoGUI library itself.
v1
DOXYGEN BUG.
Definition
algorithm.hpp:15
v1::defer
Defer execution of a lambda to the end of the scope.
Definition
defer.hpp:21
std::move
T move(T... args)
Generated on Mon Apr 22 2024 12:53:20 for HikoGUI by
1.10.0