added return value for emplace ()

This commit is contained in:
Niels Lohmann 2016-11-28 18:33:46 +01:00
parent 6ecff31b7f
commit aeb4f87a27
6 changed files with 82 additions and 20 deletions
doc/examples

View file

@ -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';
}