idea about mapping macros and more #908
Replies: 1 comment 1 reply
-
Glaze had these macros (see old file), but intentionally deprecated them not long ago. The nlohmann examples of using this macro NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT can be purely reflection with Glaze and don't require any typing at all. In cases where If you could provide an example of what you consider to be verbose, there may be ways to simplify the code. Or, you could rename the old glaze macros and use them yourself if you wanted. Some reasons to avoid the macros:
Another major reason to not use macros is that we want to support C++20 modules, which disallows exporting macros. On your other point of supporting glz::read with C arrays, this is very desirable and I've opened an issue here #909. I will note that you can use lambda wrappers with struct my_struct
{
uint32_t array[4]{};
struct glaze {
static constexpr auto value = glz::object("array", [](auto& s){ return std::span{ s.array, 4 }; });
};
}; |
Beta Was this translation helpful? Give feedback.
-
Is it possible to create macros to facilitate struct mapping, something similar to NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT from the nlohmann library?
current manual mapping is very verbose and tiring.
Something that could also help would be the possibility of using glz::read with C arrays for legacy projects, I saw that in auto mapping it is possible to create a C char array, this is very good, I could bring this to the others also, even if it was initially manual mapping
Beta Was this translation helpful? Give feedback.
All reactions