HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
utils.hpp
1
// Copyright Take Vos 2020, 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
#pragma once
6
7
#include <atomic>
8
#include <utility>
9
19
#define hi_get_overloaded_macro2(_1, _2, name, ...) name
20
21
namespace
hi::inline
v1
{
22
26
template
<
typename
T,
typename
U>
27
[[nodiscard]]
bool
compare_store
(T &lhs, U &&rhs)
noexcept
28
{
29
if
(lhs != rhs) {
30
lhs = std::forward<U>(rhs);
31
return
true
;
32
}
else
{
33
return
false
;
34
}
35
}
36
42
template
<
typename
T,
typename
U>
43
[[nodiscard]]
bool
compare_store
(
std::atomic<T>
&lhs, U &&rhs)
noexcept
44
{
45
return
lhs.exchange(rhs, std::memory_order::relaxed) != rhs;
46
}
47
48
}
// namespace hi::inline v1
v1
DOXYGEN BUG.
Definition
algorithm.hpp:15
v1::compare_store
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition
utils.hpp:27
std::atomic
Generated on Mon Apr 22 2024 12:53:22 for HikoGUI by
1.10.0