📝 updated documentation for items() function

This commit is contained in:
Niels Lohmann 2018-12-21 22:51:12 +01:00
parent 98f4e31c3e
commit 1107f8cd82
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
2 changed files with 28 additions and 6 deletions

View file

@ -4340,9 +4340,20 @@ class basic_json
Range-based for loop with `items()` function:
@code{cpp}
for (auto it : j_object.items())
for (auto& el : j_object.items())
{
std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
}
@endcode
The `items()` function also allows to use
[structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding)
(C++17):
@code{cpp}
for (auto& [key, val] : j_object.items())
{
std::cout << "key: " << key << ", value:" << val << '\n';
}
@endcode
@ -4360,7 +4371,7 @@ class basic_json
@complexity Constant.
@since version 3.1.0.
@since version 3.1.0, structured bindings support since 3.5.0.
*/
iteration_proxy<iterator> items() noexcept
{

View file

@ -16720,9 +16720,20 @@ class basic_json
Range-based for loop with `items()` function:
@code{cpp}
for (auto it : j_object.items())
for (auto& el : j_object.items())
{
std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
}
@endcode
The `items()` function also allows to use
[structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding)
(C++17):
@code{cpp}
for (auto& [key, val] : j_object.items())
{
std::cout << "key: " << key << ", value:" << val << '\n';
}
@endcode
@ -16740,7 +16751,7 @@ class basic_json
@complexity Constant.
@since version 3.1.0.
@since version 3.1.0, structured bindings support since 3.5.0.
*/
iteration_proxy<iterator> items() noexcept
{