mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:47:45 +00:00
AK: Prevent Atomic with complex types
This would throw some really weird linker errors, so let's prevent it from happening instead!
This commit is contained in:
parent
d905de6a7a
commit
7418bdb85f
1 changed files with 4 additions and 0 deletions
|
@ -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>
|
template<typename T, MemoryOrder DefaultMemoryOrder = AK::MemoryOrder::memory_order_seq_cst>
|
||||||
class Atomic {
|
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 };
|
T m_value { 0 };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue