STL containers element destruction order

前端 未结 2 1678
忘了有多久
忘了有多久 2020-11-30 08:58

Does ISO C++ standard mandate any sort of destruction order of objects inside STL containers?

  • Are std::list/std::vector/std::ma
相关标签:
2条回答
  • 2020-11-30 09:06
    1. Unspecified in the standard.
    2. Yes, but this means that the key is destroyed after its associated value.
    0 讨论(0)
  • 2020-11-30 09:06
    1. Unspecified
    2. Yes, you can depend on std::map storing it's elements in std::pairs, but I don't see anything which specifies the Key portion of a std::pair being destructed before a Value portion.
    0 讨论(0)
提交回复
热议问题