From 83055a95d6b1fbe6ec8e411829a1731f492288bf Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 30 Jun 2026 14:20:55 +0200 Subject: [PATCH] :bug: fix ambiguous static_cast Signed-off-by: Niels Lohmann --- include/nlohmann/detail/output/binary_writer.hpp | 4 +++- single_include/nlohmann/json.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index d0c947bba..6c2ad70bc 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1634,7 +1634,9 @@ class binary_writer }; string_t key = "_ArrayType_"; - auto it = bjdtype.find(static_cast(value.at(key))); + // use get() instead of static_cast to avoid an + // ambiguous conversion under explicit instantiation on C++17 (see #4825) + auto it = bjdtype.find(value.at(key).template get()); if (it == bjdtype.end()) { return true; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 36c1f1510..5c661684d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17820,7 +17820,9 @@ class binary_writer }; string_t key = "_ArrayType_"; - auto it = bjdtype.find(static_cast(value.at(key))); + // use get() instead of static_cast to avoid an + // ambiguous conversion under explicit instantiation on C++17 (see #4825) + auto it = bjdtype.find(value.at(key).template get()); if (it == bjdtype.end()) { return true;