mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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
Notes:
sideshowbarker
2024-07-17 01:46:43 +09:00
Author: https://github.com/alimpfard
Commit: 0e61d039c9
Pull-request: https://github.com/SerenityOS/serenity/pull/22959
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 11 additions and 5 deletions
|
@ -104,11 +104,17 @@ public:
|
|||
|
||||
Optional<FlatPtr> get_addr() const
|
||||
{
|
||||
#ifdef __LP64__
|
||||
return get_u64();
|
||||
#else
|
||||
return get_u32();
|
||||
#endif
|
||||
// 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();
|
||||
} else {
|
||||
return get_u32();
|
||||
}
|
||||
};
|
||||
|
||||
return fn.operator()<FlatPtr>();
|
||||
}
|
||||
|
||||
Optional<bool> get_bool() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue