mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
✨ added return value for emplace (#349)
This commit is contained in:
@ -13,11 +13,18 @@ int main()
|
||||
std::cout << null << '\n';
|
||||
|
||||
// add values
|
||||
object.emplace("three", 3);
|
||||
auto res1 = object.emplace("three", 3);
|
||||
null.emplace("A", "a");
|
||||
null.emplace("B", "b");
|
||||
|
||||
// the following call will not add an object, because there is already
|
||||
// a value stored at key "B"
|
||||
auto res2 = null.emplace("B", "c");
|
||||
|
||||
// print values
|
||||
std::cout << object << '\n';
|
||||
std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
|
||||
|
||||
std::cout << null << '\n';
|
||||
std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/Qg5Ogrh8yFrwT2GY"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/B6ILaoysGMliouEO"><b>online</b></a>
|
@ -1,4 +1,6 @@
|
||||
{"one":1,"two":2}
|
||||
null
|
||||
{"one":1,"three":3,"two":2}
|
||||
3 true
|
||||
{"A":"a","B":"b"}
|
||||
"b" false
|
||||
|
Reference in New Issue
Block a user