From 75c61f91f1909b932b6feabcc41bc8e212fd82d2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 23 Sep 2026 22:38:46 +0200 Subject: [PATCH] Declare hash_frame's constructor noexcept GCC's -Wnoexcept (an error in CI) flags the emplace_back() into the hash stack under C++26: the constructor cannot throw, since cbegin() is noexcept, but it did not say so. dump_frame's constructor is noexcept for the same reason. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/hash.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 0b3d1e2a5..49177366e 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -161,7 +161,7 @@ std::size_t hash(const BasicJsonType& j, const std::size_t depth = 0) template struct hash_frame { - hash_frame(const BasicJsonType* value_, std::size_t seed_) + hash_frame(const BasicJsonType* value_, std::size_t seed_) noexcept : value(value_), position(value_->cbegin()), seed(seed_) {} diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5813dc189..3745c365a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7136,7 +7136,7 @@ std::size_t hash(const BasicJsonType& j, const std::size_t depth = 0) template struct hash_frame { - hash_frame(const BasicJsonType* value_, std::size_t seed_) + hash_frame(const BasicJsonType* value_, std::size_t seed_) noexcept : value(value_), position(value_->cbegin()), seed(seed_) {}