3 ms·
The problem with deconstructing a tuple is that you can easily make mistake about the order of its members. The struct is a much better solution to me, and you
by matt42 11y ago
The problem with deconstructing a tuple is that you can easily make mistake about the order of its members. The struct is a much better solution to me, and you can go over the problem of the weirdly named one-off struct by using the iod library (https://github.com/matt-42/iod https://github.com/matt-42/iod):
foo() { return D(_id = "test", _age = "42" }; }
auto r = foo();
std::cout << r.id << r.age << std::endl;
- ericfrederich 11y agoMeaningful names would be nice. In C++ iterating over a map items you get a pair with ->first() and ->second() methods instead of key / value. Python has named tuples which can work both ways.