My impression is that it is always better to define my own struct, such that I can use meaningful field names instead of first
and second
.
One place where the standard uses std::pair
is for accessing elements of std::map
. first
is the key, and second
the value. Would not it be much better to have a specific key_value_pair
template, and refer to its fields as key
and value
instead of first
and second
? It seems to me that it would make code considerably more readable at no cost.