From ea667db446649a9beb5689e6e5b860831d06323e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 3 Apr 2017 21:53:23 +0200 Subject: [PATCH] :hammer: fixed compilation errors TIL about C++: executing m[key()]=val(); for a std::map executes First key() then val() with Clang First val() then key() with GCC #wat --- src/json.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index e96a53e3a..9fadcae82 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -10722,7 +10722,8 @@ class basic_json for (size_t i = 0; i < len; ++i) { get(); - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; } @@ -10734,7 +10735,8 @@ class basic_json for (size_t i = 0; i < len; ++i) { get(); - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; } @@ -10746,7 +10748,8 @@ class basic_json for (size_t i = 0; i < len; ++i) { get(); - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; } @@ -10758,7 +10761,8 @@ class basic_json for (size_t i = 0; i < len; ++i) { get(); - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; } @@ -10770,7 +10774,8 @@ class basic_json for (size_t i = 0; i < len; ++i) { get(); - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; } @@ -10780,7 +10785,8 @@ class basic_json basic_json result = value_t::object; while (get() != 0xff) { - result[get_cbor_string()] = parse_cbor(); + auto key = get_cbor_string(); + result[key] = parse_cbor(); } return result; }