What is std::pair
for, why would I use it, and what benefits does boost::compressed_pair
bring?
What is std::pair for, why would I use it?
It is just as simple two elements tuple. It was defined in first version of STL in times when compilers were not widely supporting templates and metaprogramming techniques which would be required to implement more sophisticated type of tuple like Boost.Tuple.
It is useful in many situations. std::pair
is used in standard associative containers. It can be used as a simple form of range std::pair
- so one may define algorithms accepting single object representing range instead of two iterators separately.
(It is a useful alternative in many situations.)