加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C std :: set为什么是关联的?

发布时间:2020-12-16 07:53:12 所属栏目:百科 来源:网络整理
导读:为什么std :: set定义为关联容器? 我的意思是std :: map是一个关联容器,因为它将一个值映射到一个键,但为什么它是一个集合? 解决方法 23.4.6.1类模板集概述[set.overview] A set satisfies all of the requirements of [..] an associative container (23.
为什么std :: set定义为关联容器?

我的意思是std :: map是一个关联容器,因为它将一个值映射到一个键,但为什么它是一个集合?

解决方法

23.4.6.1类模板集概述[set.overview]

A set satisfies all of the requirements of [..] an associative
container (23.2.4) […]

因为它满足了23.2.4中描述的作为关联容器的所有前提条件.并不像“将一个键映射到一个值”那么简单.

第二段甚至强调了这一点(或者更确切地说,事实上,映射和多重映射在关联容器上具有附加功能):

23.2.4关联容器[associative.reqmts]

2) Each associative container is parameterized on Key and an ordering relation Compare that induces a strict
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.

完整的段落太大,无法在这里重现.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读