mirror of
https://github.com/nlohmann/json.git
synced 2024-11-23 22:19:02 +08:00
Improve error message for const fields
This commit is contained in:
parent
71a514a651
commit
249493264a
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user