Skip to content

Commit

Permalink
📝 add warning for items() on temporary objects #2040
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed May 14, 2020
1 parent 0857140 commit bcf4f3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bcf4f3c

Please sign in to comment.