Improve error message for const fields

This commit is contained in:
Alexander Lanin 2021-06-14 23:02:08 +02:00
parent 71a514a651
commit 249493264a
2 changed files with 2 additions and 0 deletions

View File

@ -3236,6 +3236,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
ValueType & get_to(ValueType& v) const noexcept(noexcept(
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
{
static_assert(!std::is_const<ValueType>::value, "Cannot deserialize into constant fields");
JSONSerializer<ValueType>::from_json(*this, v);
return v;
}

View File

@ -20256,6 +20256,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
ValueType & get_to(ValueType& v) const noexcept(noexcept(
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
{
static_assert(!std::is_const<ValueType>::value, "Cannot deserialize into constant fields");
JSONSerializer<ValueType>::from_json(*this, v);
return v;
}