|
|
|
|
|
by comex
141 days ago
|
|
This kind of automatic property serialization/deserialization, however, has traditionally been a sore spot for C++ as well. You can do it, but you will have to either repeat yourself at least a little, use some very ugly macros, or use a code generator. And many of those ugly macro tricks work in C as well. So do code generators. That said, as C++ has added features, this type of metaprogramming has gotten easier and easier, and more and more distinct from C. This culminates in C++26 reflection which will finally make it possible to just define a struct and then automatically generate serialization/deserialization for it, without hacks. Once reflection is implemented and widely adopted, then I will agree with you that this should be 1 or 2 lines in a well-structured C++ app. |
|