mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
AK: Use IsSame<FlatPtr, T> instead of __LP64__ to guess FlatPtr's type
Instead of playing the guessing game, simply use whatever type FlatPtr itself resolves to.
This commit is contained in:
parent
9326ded5a4
commit
0e61d039c9
1 changed files with 11 additions and 5 deletions
|
@ -104,11 +104,17 @@ public:
|
||||||
|
|
||||||
Optional<FlatPtr> get_addr() const
|
Optional<FlatPtr> get_addr() const
|
||||||
{
|
{
|
||||||
#ifdef __LP64__
|
// Note: This makes the lambda dependent on the template parameter, which is necessary
|
||||||
return get_u64();
|
// for the `if constexpr` to not evaluate both branches.
|
||||||
#else
|
auto fn = [&]<typename T>() -> Optional<T> {
|
||||||
return get_u32();
|
if constexpr (IsSame<T, u64>) {
|
||||||
#endif
|
return get_u64();
|
||||||
|
} else {
|
||||||
|
return get_u32();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return fn.operator()<FlatPtr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<bool> get_bool() const
|
Optional<bool> get_bool() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue