Serializing std::variant<T, std::vector<T>> #2045
Labels
kind: enhancement/improvement
state: needs more info
the author of the issue needs to provide more details
I am aware of #1261 , but though one special case may be considered. I use a variant to read "scalar" and "vector" of same types. The JSON code would be
To map this data into C++ I use a std::variant<double, std::vector> and found the serialization and deserialization to be a bit overly complicated.
After reading up on #1261 I understand why general purpose std::variant can not be serialized and the proposed solution there is not really useful for my use case.
I came up with the following code to integrate this use case into the built in serialization:
Obviously this is not the general / general solution as other containers should be considered and probably it can be done better. It would be nice if this use case can be included in the library, but if not I understand and this request can still be useful for posterity.
The text was updated successfully, but these errors were encountered: