mercredi 21 décembre 2016

In API design, when should I prefer a length-2 std::tuple over a pair?

I'm writing a small library which has some API function returning two things (of different types). I'm note going to declare a struct just for that; so I'm thinking of returning an std::pair<foo, bat>. But - perhaps in these modern times I should prefer returning std::tuple<foo, bar> instead?

More generally, when should a tuple be prefered over a pair, and when is pair the more appropriate construct?

Aucun commentaire:

Enregistrer un commentaire