为什么std :: set定义为关联容器?
@H_301_2@我的意思是std :: map是一个关联容器,因为它将一个值映射到一个键,但为什么它是一个集合?
解决方法
23.4.6.1类模板集概述[set.overview]
@H_301_2@A@H_301_2@因为它满足了23.2.4中描述的作为关联容器的所有前提条件.并不像“将一个键映射到一个值”那么简单. @H_301_2@第二段甚至强调了这一点(或者更确切地说,事实上,映射和多重映射在关联容器上具有附加功能): @H_301_2@23.2.4关联容器[associative.reqmts]set
satisfies all of the requirements of [..] an associative
container (23.2.4) […]
@H_301_2@2) Each associative container is parameterized on Key and an ordering relation Compare that induces a strict@H_301_2@完整的段落太大,无法在这里重现.
weak ordering (25.4) on elements of Key. In addition,map and multimap associate an arbitrary type T with
the Key. The object of type Compare is called the comparison object of a container.