问题描述
"26.4.5.1类模板多图概述"的C ++标准p1说:
C++ standard for "26.4.5.1 Class template multimap overview" p1 says:
重点是我的.那么,这是否意味着std::multimap
在插入到相等范围内并替换为相等的对象时可能不会保留原始关键对象的副本?
emphasis is mine. So does it mean that std::multimap
may not keep a copy of original key object when inserted into equal range and replace it with equal one?
PS要明确说明此问题,是受,我想知道多图是否允许这样做,即我可以依靠它的维护能力吗?我的密钥(可以相等但不相同).
PS To make clear this question is inspired by this Does Each Element of a multimap Contain Both the Key and Value? and I want to know if multimap allowed to do that ie can I rely on its ability to maintain my key (which could be equal but not the same).
推荐答案
否.该标准描述了如何在此表中插入元素.例如,a_eq.emplace(args)
的作用描述如下(强调我的意思).
No. The standard describes how an element is inserted in this table. For example, the effect of a_eq.emplace(args)
is described as follows (emphasis mine).
请注意,std::multimap<Key, T>
的value_type
是std::pair<const Key, T>
,因此必须构造相同的键(不仅等效).
Note the value_type
of std::multimap<Key, T>
is std::pair<const Key, T>
, so a same (not only equivalent) key must be constructed.
这篇关于`std :: multimap`是否保证每个键的实际值在相等的范围内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!