-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
get<T> for types that are not default constructible #996
Comments
Do you have a concrete example for this? |
There is a way to deserialize non-default constructible types, you can see this section for more details. |
As for your suggestion, the problem is that Even if your j.get<MyClass>(1, 2); // first constructor
j.get<MyClass>(); // default constructor
j.get<MyClass>("") // another constructor I think this can lead to lots of complex handling inside functions, so I would rather keep the conversion functions with lowest side-effects as possible. |
Just to make sure I understand - your concern is different constructors might leave the I can use the approach of specializing |
Yes that's exactly it :) |
Thanks @theodelrieu ! |
Currently the
get<T>
method requires that T is default constructible. Might it make sense to overloadget
so that it can take variadic arguments and construct the new object with a non-default constructor? For example - below is a minor variation ofget
. Any reason why this is a bad idea?The text was updated successfully, but these errors were encountered: