pair
looks like this:
std::vector<std::pair<uint64 /*id*/, std::string /*message*/>
And if I want 3 variables in vector
? Can I use pair or what?
pair
looks like this:
std::vector<std::pair<uint64 /*id*/, std::string /*message*/>
And if I want 3 variables in vector
? Can I use pair or what?
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.