Constructors added to structs seem to mess with the serialization. #767
-
I am not sure if this is a bug or the glaze contract states that constructors added to struct produce undefined behavior. So I have the following setup.
Output:
With both constructors defined:
Well adding metadata for the B structure fixes the problem, but not having it defined does not assert. It also feels like it should not be necessary to add that metadata since it's only when A is wrapped in another struct that it causes problems. I did not create an issue since I am not sure if this is a bug or not. I though it is better to just ask here. maybe i am just not understanding the structure of the library good enough or i am doing something wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've documented the fix here as well: #721. The solution is to add another constructor that enables brace initialization for Glaze. Simply add the following constructor: In full: struct A {
int x = 0;
A(glz::make_reflectable) {}
A() = default;
A(int) {}; //Comment & uncomment this constructor.
}; |
Beta Was this translation helpful? Give feedback.
I've documented the fix here as well: #721. The solution is to add another constructor that enables brace initialization for Glaze.
Simply add the following constructor:
A(glz::make_reflectable) {}
In full: