📝 add warning for items() on temporary objects #2040

This commit is contained in:
Niels Lohmann 2020-05-14 19:06:48 +02:00
parent 0857140839
commit bcf4f3ce9a
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
2 changed files with 10 additions and 0 deletions

View file

@ -4946,6 +4946,11 @@ class basic_json
element as string (see example). For primitive types (e.g., numbers),
`key()` returns an empty string.
@warning Using `items()` on temporary objects is dangerous. Make sure the
object's lifetime exeeds the iteration. See
<https://github.com/nlohmann/json/issues/2040> for more
information.
@return iteration proxy object wrapping @a ref with an interface to use in
range-based for loops

View file

@ -20437,6 +20437,11 @@ class basic_json
element as string (see example). For primitive types (e.g., numbers),
`key()` returns an empty string.
@warning Using `items()` on temporary objects is dangerous. Make sure the
object's lifetime exeeds the iteration. See
<https://github.com/nlohmann/json/issues/2040> for more
information.
@return iteration proxy object wrapping @a ref with an interface to use in
range-based for loops