Replies: 5 comments 10 replies
-
I was constructing glz::read_as expression and got that idea so fast typed it for You. |
Beta Was this translation helpful? Give feedback.
-
I posted it because it is annoying to work with field initializers, i have to look at original order to have correct code
ISO C++ requires field designators to be specified in declaration order; field 'skip_null_members' will be initialized after field 'error_on_unknown_keys' [-Wreorder-init-list] |
Beta Was this translation helpful? Give feedback.
-
I like this idea. Another idea I've been considering is bit packing booleans in a uint64_t. So you can combine options like The sequence doesn't matter, but the downsides are that this only works with booleans and we'd have to reword the options such that the default value of all options is false. A benefit of this approach is that compilation errors are shorter because the compiler will display one integer for up to 64 booleans. I just wanted to put this out as an alternative idea, but I think I prefer your approach. I do expect change how options are handled in the future, I just want to carefully consider various solutions before making a major API change. |
Beta Was this translation helpful? Give feedback.
-
I really like the strong typing. |
Beta Was this translation helpful? Give feedback.
-
I just thought of a perhaps even better approach. Say we use a std::tuple of strongly typed option within glz::opts{ format::json, comments::yes } This would store a std::tuple<format, comments>, and we could check with C++20 concepts whether the tuple contains various options. If other options are not set, then the default behavior is used. The benefit of this approach is that our I feel like this would provide the cleanest solution. The only worry I have is if the additional type searching will have an impact on compile times. But, I wouldn't think it would be significant. |
Beta Was this translation helpful? Give feedback.
-
It should work something like this
Beta Was this translation helpful? Give feedback.
All reactions