Is it safe to return string.c_str() received from get()? #2130
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
What do you want to achieve?
I'm building a function
const char* GetName(id)
.Data is stored in json file, e.g.
[{"name":"N1"}, {"name":"N2"}, {"name":"N3"}]
Is it safe for my function to return c_str pointers from
std::string
received fromget()
? I'm not sure aboutstd::string
objects lifecycle insidenlohmann::json
.Example:
The text was updated successfully, but these errors were encountered: