1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:57:34 +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:
Ali Mohammad Pur 2024-01-27 13:34:13 +03:30 committed by Ali Mohammad Pur
parent 9326ded5a4
commit 0e61d039c9

View file

@ -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
// for the `if constexpr` to not evaluate both branches.
auto fn = [&]<typename T>() -> Optional<T> {
if constexpr (IsSame<T, u64>) {
return get_u64(); return get_u64();
#else } else {
return get_u32(); return get_u32();
#endif }
};
return fn.operator()<FlatPtr>();
} }
Optional<bool> get_bool() const Optional<bool> get_bool() const