Better support for non-default-constructable datatypes #2335
Closed
Ericson2314
started this conversation in
Ideas
Replies: 2 comments
-
Maybe related: #2576 |
Beta Was this translation helpful? Give feedback.
0 replies
-
The ADL |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have read the docs on how this library does in fact support deserializing to non-default-constructable types. The problem is that it's not very compositional: for example, there is no way to write a generic instance for
std::variant<Ts..>
that works if all ofTs..
aren't default construable. Evenstd::option<T>
, which is itself default construable no matter ifT
is, would be a bit hard to write in an exception-safe way.In my own code (https://github.com/NixOS/nix/pull/3859/files#diff-48ed85ec1c3c2412447bedb0e859275a if anyone is curious) I tried a different technique to get around this, which adopted to this library would look something like
the idea is that
Proxy
guides overloading so we can effectively overload the return type.Beta Was this translation helpful? Give feedback.
All reactions