-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Hello!
After reading https://github.com/getml/reflect-cpp/blob/main/docs/variants_and_tagged_unions.md I was under the impression that I would be able to do something like:
struct Rectangle { /*...*/ };
struct Circle { /*...*/ };
struct Shape {
std::string custom_name;
rfl::Variant<rfl::Field<"rectangle", Rectangle>, rfl::Field<"circle", Circle>> shape;
}; // <-- struct Shapebut it still requires for the "shape" member to be present in JSON and only under that does generate the correct children. I tried to rfl::Flatten it, but it gave a compile-time error.
I understand, this is not really supported at that moment? How hard will it be to add it? Where should I start if I wanted to add support for such syntax?
P.S. Ofc this could be done by making Shape a template and (de)serializing a variant on that, but I really wanted to avoid it. Unless, of course, reflect-cpp is strictly tied to the idea of struct having a fixed set independent fields and there is no way to fit syntax like that into the design of the library.