Add assertion to converting constructor

The converting basic_json constructor can inadvertently change the value
type of its parameter. Assert that both basic_json values are of the
same value type after conversion.
This commit is contained in:
Florian Albrechtskirchinger 2022-06-03 16:34:55 +02:00
parent 6058d9a8b3
commit 4b75ae6828
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D
2 changed files with 2 additions and 0 deletions

View File

@ -916,6 +916,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
}
JSON_ASSERT(m_type == val.type());
set_parents();
assert_invariant();
}

View File

@ -19190,6 +19190,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
}
JSON_ASSERT(m_type == val.type());
set_parents();
assert_invariant();
}