STL容器元素销毁顺序 [英] STL containers element destruction order
本文介绍了STL容器元素销毁顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ISO C ++标准是否要求对STL容器内的对象执行任何形式的销毁顺序?
Does ISO C++ standard mandate any sort of destruction order of objects inside STL containers?
-
std::list
/std::vector
/std::map
元素是否从容器的开头或结尾开始被破坏? - 我可以依靠
std::map
在内部将其元素存储在std::pair
中,以便在键对中的键在其值之前被销毁(反之亦然)吗?
- Are
std::list
/std::vector
/std::map
elements destroyed starting from the beginning or the end of the container? - Can I rely on
std::map
storing its elements instd::pair
s internally so a key in a pair is destroyed before its value (or vice versa)?
推荐答案
- 标准中未指定.
- 是的,但这意味着密钥在 关联值之后被销毁.
- Unspecified in the standard.
- Yes, but this means that the key is destroyed after its associated value.
这篇关于STL容器元素销毁顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文