mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
AK: Fix UFixedBigInt
not building with Clang
Clang does not like that we are trying to refer to our own size while our declaration is not yet complete, and fails to compile this file. This is fixed by introducing a function which returns the correct sizeof. This only gets evaluated in the `requires` clause after the whole class has been parsed, so it will compile fine.
This commit is contained in:
parent
494ead3eb8
commit
2ee39ed5f0
Notes:
sideshowbarker
2024-07-18 10:05:20 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/2ee39ed5f0d Pull-request: https://github.com/SerenityOS/serenity/pull/8470 Reviewed-by: https://github.com/Dexesttp Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/gunnarbeutner ✅
1 changed files with 8 additions and 4 deletions
|
@ -54,7 +54,6 @@ public:
|
|||
, m_high(high)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr T& low()
|
||||
{
|
||||
return m_low;
|
||||
|
@ -314,6 +313,11 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
static constexpr size_t my_size()
|
||||
{
|
||||
return sizeof(R);
|
||||
}
|
||||
|
||||
// Arithmetics
|
||||
|
||||
// implies size of less than u64, so passing references isn't useful
|
||||
|
@ -335,7 +339,7 @@ public:
|
|||
};
|
||||
}
|
||||
template<Unsigned U>
|
||||
requires(sizeof(R) > sizeof(U) && sizeof(T) > sizeof(u64)) constexpr R addc(const U& other, bool& carry) const
|
||||
requires(my_size() > sizeof(U) && sizeof(T) > sizeof(u64)) constexpr R addc(const U& other, bool& carry) const
|
||||
{
|
||||
T lower = m_low.addc(other, carry);
|
||||
T higher = m_high.addc(0u, carry);
|
||||
|
@ -377,7 +381,7 @@ public:
|
|||
};
|
||||
}
|
||||
template<Unsigned U>
|
||||
requires(sizeof(R) < sizeof(U)) constexpr U addc(const U& other, bool& carry) const
|
||||
requires(my_size() < sizeof(U)) constexpr U addc(const U& other, bool& carry) const
|
||||
{
|
||||
return other.addc(*this, carry);
|
||||
}
|
||||
|
@ -474,7 +478,7 @@ public:
|
|||
|
||||
// FIXME: no restraints on this
|
||||
template<Unsigned U>
|
||||
requires(sizeof(R) >= sizeof(U)) constexpr R div_mod(const U& divisor, U& remainder) const
|
||||
requires(my_size() >= sizeof(U)) constexpr R div_mod(const U& divisor, U& remainder) const
|
||||
{
|
||||
// FIXME: Is there a better way to raise a division by 0?
|
||||
// Maybe as a compiletime warning?
|
||||
|
|
Loading…
Add table
Reference in a new issue