What is std::pair?

前端 未结 10 1726
面向向阳花
面向向阳花 2020-12-12 19:07

What is std::pair for, why would I use it, and what benefits does boost::compressed_pair bring?

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 20:06

    std::pair comes in handy for a couple of the other container classes in the STL.

    For example:

    std::map<>
    std::multimap<> 
    

    Both store std::pairs of keys and values.

    When using the map and multimap, you often access the elements using a pointer to a pair.

提交回复
热议问题