-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
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:
template <typename T>
T& json::get(T& x) const { return x = get<T>(); }
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.
auto& x = . . .;
json.get(x);
Which can be quite a bit less verbose than
auto& x = . . .;
x = json.get<std::decay_t<decltype(x)>>();
Thanks for the amazing library,
Ivan
Metadata
Metadata
Assignees
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation