🚑 fix regression from #2181

This commit is contained in:
Niels Lohmann 2020-07-08 14:02:28 +02:00
parent d019ddfcdb
commit e3e9ccfc02
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
4 changed files with 27 additions and 18 deletions

View file

@ -1945,6 +1945,15 @@ TEST_CASE("regression tests")
)
);
}
SECTION("PR #2181 - regression bug with lvalue")
{
// see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060
json j{{"x", "test"}};
std::string defval = "default value";
auto val = j.value("x", defval);
auto val2 = j.value("y", defval);
}
}
#if not defined(JSON_NOEXCEPTION)

View file

@ -60,9 +60,9 @@ class person_with_private_data
class person_without_private_data_1
{
public:
std::string name = "";
int age = 0;
json metadata = nullptr;
std::string name = "";
int age = 0;
json metadata = nullptr;
bool operator==(const person_without_private_data_1& rhs) const
{
@ -82,9 +82,9 @@ class person_without_private_data_1
class person_without_private_data_2
{
public:
std::string name = "";
int age = 0;
json metadata = nullptr;
std::string name = "";
int age = 0;
json metadata = nullptr;
bool operator==(const person_without_private_data_2& rhs) const
{