🐛 fix returning reference to local temporary object #2064

pull/2069/head
Niels Lohmann 2020-04-27 14:43:49 +02:00
parent d9d1279a94
commit 9e0180b698
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
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()

View File

@ -826,7 +826,7 @@ TEST_CASE("constructors")
// check that NaN is serialized to null
CHECK(j.dump() == "null");
}
}
SECTION("infinity")
{