std::pair
provides pre-written constructors and comparison operators. This also allows them to be stored in containers like std::map without you needing to write, for example, the copy constructor or strict weak ordering via operator <
(such as required by std::map
). If you don't write them you can't make a mistake (remember how strict weak ordering works?) so it's more reliable just to use std::pair
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…