In C++ sometimes I find quite useful to define trivial all-public data-only classes like
struct Event {
int id = 0;
std::string msg = "";
double time = 0.;
};
Surely a bit of typing, but IMO way better than having to use e.second
or std::get<1>(e)
instead of e.msg
everywhere in the code.
Writing is done once, reading many times. Saving writing time at the expense of increasing reading/understanding time is a Very Bad Idea.
The drawback of this approach is that you cannot access the n-th member of the structure in metaprograms, but C++ metaprogramming is terribly weak anyway for a lot of other reasons so if you really need to have non-trivial metacode I'd suggest moving out of C++ and using an external C++ code generator written in a decent language instead of template tricks and hacks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…