You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not technically an issue with the library. The exact same thing would happen if you replaced json with std::string and just had the last line. The error message also tells you what exactly you're doing wrong. You're creating a temporary and returning it. This is bad because the temporary is destroyed before you get back to the caller. You need to return something that's going to outlast the function.
I'm not making an issue to say there's something wrong with the library. I know it's something I did wrong. I'm just asking what I should do here to return an empty JSON object.
So returning a nullconst json * is also an option?
As the title says, I need to return an empty JSON object from a function of type
const json&
. This is the function:But I'm getting this warning on it:
Basically I want to return a value indicating an error, but given the return type of the function it has to be a
const json&
object. The full code is in this Gist: https://gist.github.com/DragonOsman/d00ea7ec3d49c128ad7789293f156a09The text was updated successfully, but these errors were encountered: