本文介绍了`std :: multimap`是否保证每个键的实际值在相等的范围内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"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_­typestd::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`是否保证每个键的实际值在相等的范围内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 03:41