From 0e61d039c9cdb36faa3d4117f1a9863c1b615f69 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 27 Jan 2024 13:34:13 +0330 Subject: [PATCH] AK: Use IsSame instead of __LP64__ to guess FlatPtr's type Instead of playing the guessing game, simply use whatever type FlatPtr itself resolves to. --- AK/JsonValue.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/AK/JsonValue.h b/AK/JsonValue.h index ae05aceba8..b8e7419fe9 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -104,11 +104,17 @@ public: Optional 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 = [&]() -> Optional { + if constexpr (IsSame) { + return get_u64(); + } else { + return get_u32(); + } + }; + + return fn.operator()(); } Optional get_bool() const