summaryrefslogtreecommitdiff
path: root/AK/Atomic.h
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-02-08 23:28:25 +0100
committerLinus Groh <mail@linusgroh.de>2022-02-23 00:42:49 +0000
commit7418bdb85f2e28b173b863a75968ef90b662a127 (patch)
tree509782bd14040e493de0eba36f0cf667998ea395 /AK/Atomic.h
parentd905de6a7a646a4e6178c1e9ae71229059a2a648 (diff)
downloadserenity-7418bdb85f2e28b173b863a75968ef90b662a127.zip
AK: Prevent Atomic with complex types
This would throw some really weird linker errors, so let's prevent it from happening instead!
Diffstat (limited to 'AK/Atomic.h')
-rw-r--r--AK/Atomic.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/AK/Atomic.h b/AK/Atomic.h
index 70ae6d1399..c28dfbf4e5 100644
--- a/AK/Atomic.h
+++ b/AK/Atomic.h
@@ -138,6 +138,10 @@ static inline bool atomic_is_lock_free(volatile T* ptr = nullptr) noexcept
template<typename T, MemoryOrder DefaultMemoryOrder = AK::MemoryOrder::memory_order_seq_cst>
class Atomic {
+ // FIXME: This should work through concepts/requires clauses, but according to the compiler,
+ // "IsIntegral is not more specialized than IsFundamental".
+ // Additionally, Enums are not fundamental types except that they behave like them in every observable way.
+ static_assert(IsFundamental<T> | IsEnum<T>, "Atomic doesn't support non-primitive types, because it relies on compiler intrinsics. If you put non-primitives into it, you'll get linker errors like \"undefined reference to __atomic_store\".");
T m_value { 0 };
public: