6 ms·
Sometimes "using Coordinate = std::pair<int, int>;" does have upsides, though. One example would be when using a serialisation library that knows how to handle
by lorenzhs 10y ago
Sometimes "using Coordinate = std::pair<int, int>;" does have upsides, though. One example would be when using a serialisation library that knows how to handle pairs. In that case you don't have to add (de-)serialisation code to every new class. It's also nice to be able to use std::tie for unpacking: "std::tie(x, y) = get_coords(blah);"
If you use the members a lot, a struct with named members really is much easier to read, though.