-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json::get function with argument #1227
Comments
get
function with type deduction
Hello, I think it would be a good addition indeed, as it would reduce The ideal use-case for the current About the conversion operator, you can look at #958 for detailed information about why it doesn't always work. |
Takes an lvalue reference, and returns the same reference. This allows non-default constructible types to be used with get. This overload does not require CopyConstructible either. Implements nlohmann#1227
Takes an lvalue reference, and returns the same reference. This allows non-default constructible types to be used with get. This overload does not require CopyConstructible either. Implements nlohmann#1227
Takes an lvalue reference, and returns the same reference. This allows non-default constructible types to be used with get. This overload does not require CopyConstructible either. Conversion to C arrays is possible with this overload. Implements nlohmann#1227
Takes an lvalue reference, and returns the same reference. This allows non-default constructible types to be used with get. This overload does not require CopyConstructible either. Conversion to C arrays is possible with this overload. Implements nlohmann#1227
Takes an lvalue reference, and returns the same reference. This allows non-default constructible types to be converted without specializing adl_serializer. This overload does not require CopyConstructible either. Implements nlohmann#1227
The conversion operator template appears to not work for some types.
We just had a discussion about this on stack overflow (and an earlier one here).
Here's an example on Godbolt using
GCC
with-std=c++14
. With-std=c++17
there's no error, but still a warning.I would like to suggest a way for working around this.
Another version of the
get
function can be implemented like this:so that the type may be deduced from the argument.
This would help particularly in situations where one has a reference to an object that needs to be given value from json, e.g.
Which can be quite a bit less verbose than
Thanks for the amazing library,
Ivan
The text was updated successfully, but these errors were encountered: