Merge pull request #2069 from nlohmann/issue2064

Fix returning reference to local temporary object
This commit is contained in:
Niels Lohmann 2020-04-28 20:56:48 +02:00 committed by GitHub
commit b1fe6ee0d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View file

@ -2757,6 +2757,18 @@ class basic_json
return is_binary() ? m_value.binary : nullptr;
}
/// get a pointer to the value (binary)
internal_binary_t* get_impl_ptr(internal_binary_t* /*unused*/) noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/// get a pointer to the value (binary)
constexpr const internal_binary_t* get_impl_ptr(const internal_binary_t* /*unused*/) const noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/*!
@brief helper function to implement get_ref()

View file

@ -18243,6 +18243,18 @@ class basic_json
return is_binary() ? m_value.binary : nullptr;
}
/// get a pointer to the value (binary)
internal_binary_t* get_impl_ptr(internal_binary_t* /*unused*/) noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/// get a pointer to the value (binary)
constexpr const internal_binary_t* get_impl_ptr(const internal_binary_t* /*unused*/) const noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/*!
@brief helper function to implement get_ref()