vecmem 1.14.0
Loading...
Searching...
No Matches
atomic_ref.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2024 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10#if __cpp_concepts >= 201907L
11#include <concepts>
12
13#include "vecmem/memory/memory_order.hpp"
14#endif
15
16namespace vecmem::concepts {
17#if __cpp_concepts >= 201907L
21template <typename T>
22concept atomic_ref = requires {
23 typename T::value_type;
24
25 requires requires(const T& r, typename T::value_type v) {
26 { r = v }
27 ->std::same_as<typename T::value_type>;
28 };
29
30 requires requires(const T& r, memory_order o) {
31 { r.load(o) }
32 ->std::same_as<typename T::value_type>;
33 };
34
35 requires requires(const T& r, typename T::value_type v, memory_order o) {
36 { r.store(v, o) }
37 ->std::same_as<void>;
38 { r.exchange(v, o) }
39 ->std::same_as<typename T::value_type>;
40 { r.fetch_add(v, o) }
41 ->std::same_as<typename T::value_type>;
42 { r.fetch_sub(v, o) }
43 ->std::same_as<typename T::value_type>;
44 { r.fetch_and(v, o) }
45 ->std::same_as<typename T::value_type>;
46 { r.fetch_or(v, o) }
47 ->std::same_as<typename T::value_type>;
48 { r.fetch_xor(v, o) }
49 ->std::same_as<typename T::value_type>;
50 };
51
52 requires requires(const T& r, typename T::value_type& e,
53 typename T::value_type d, memory_order o1,
54 memory_order o2) {
55 { r.compare_exchange_strong(e, d, o1, o2) }
56 ->std::same_as<bool>;
57 { r.compare_exchange_strong(e, d, o1) }
58 ->std::same_as<bool>;
59 };
60};
61#endif
62} // namespace vecmem::concepts
memory_order
Custom (dummy) definition for the memory order.
Definition memory_order.hpp:31