Skip to content

Commit

Permalink
Improve error message for const fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLanin committed Jun 14, 2021
1 parent 71a514a commit 2494932
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2494932

Please sign in to comment.