From 80688bd32ad7a581aa8b28a2f0de10d294f86e0f Mon Sep 17 00:00:00 2001 From: Carl Smedstad Date: Mon, 27 Sep 2021 21:02:43 +0200 Subject: [PATCH] Add assert_invariant call to catch errors earlier --- include/nlohmann/json.hpp | 1 + single_include/nlohmann/json.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 594ba0d2a..c683d2522 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3713,6 +3713,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); } #endif + assert_invariant(); } return m_value.array->operator[](idx); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 3f8140e67..5899a7945 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -21119,6 +21119,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); } #endif + assert_invariant(); } return m_value.array->operator[](idx);