-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
Description
In the Readme, the following example is provided:
for (auto element : j) {
std::cout << element << '\n';
}
Does this end up creating a copy of each array element during each iteration?
Are
for (const auto &element : j) {
std::cout << element << '\n';
}
and
for (auto &element : j) {
element["a"]=...;
}
better alternatives or is the version in the readme the optimal usage for all scenarios?
(In some sense this is just a basic c++ question. I don't really know how ranged for loop work in c++, or how to actually check what is happening in each of the scenarios, but in any case I am specifically curious about it works for basic_json's implementation)
Thanks!
Reactions are currently unavailable