• <bdo id='TnO05'></bdo><ul id='TnO05'></ul>

    1. <small id='TnO05'></small><noframes id='TnO05'>

    2. <legend id='TnO05'><style id='TnO05'><dir id='TnO05'><q id='TnO05'></q></dir></style></legend>

        <i id='TnO05'><tr id='TnO05'><dt id='TnO05'><q id='TnO05'><span id='TnO05'><b id='TnO05'><form id='TnO05'><ins id='TnO05'></ins><ul id='TnO05'></ul><sub id='TnO05'></sub></form><legend id='TnO05'></legend><bdo id='TnO05'><pre id='TnO05'><center id='TnO05'></center></pre></bdo></b><th id='TnO05'></th></span></q></dt></tr></i><div id='TnO05'><tfoot id='TnO05'></tfoot><dl id='TnO05'><fieldset id='TnO05'></fieldset></dl></div>
        <tfoot id='TnO05'></tfoot>

      1. std::vector 元素的销毁顺序

        Order of destruction of elements of an std::vector(std::vector 元素的销毁顺序)
        • <i id='19c5X'><tr id='19c5X'><dt id='19c5X'><q id='19c5X'><span id='19c5X'><b id='19c5X'><form id='19c5X'><ins id='19c5X'></ins><ul id='19c5X'></ul><sub id='19c5X'></sub></form><legend id='19c5X'></legend><bdo id='19c5X'><pre id='19c5X'><center id='19c5X'></center></pre></bdo></b><th id='19c5X'></th></span></q></dt></tr></i><div id='19c5X'><tfoot id='19c5X'></tfoot><dl id='19c5X'><fieldset id='19c5X'></fieldset></dl></div>

          <small id='19c5X'></small><noframes id='19c5X'>

        • <tfoot id='19c5X'></tfoot>
            <bdo id='19c5X'></bdo><ul id='19c5X'></ul>
              <tbody id='19c5X'></tbody>
            1. <legend id='19c5X'><style id='19c5X'><dir id='19c5X'><q id='19c5X'></q></dir></style></legend>

                  本文介绍了std::vector 元素的销毁顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能的重复:
                  STL容器元素销毁顺序

                  有没有保证 std::vector 的元素会从最后到第一个销毁?

                  Is there a guarantee the the elements of an std::vector would be destroyed from last to first?

                  推荐答案

                  2003:5.3.5/6 关于 delete[] 的说明:

                  2003:5.3.5/6 says about delete[]:

                  delete 表达式将调用要删除的对象或数组元素的析构函数(如果有).在数组的情况下,元素将按照地址递减的顺序销毁(即,按照其构造函数完成的相反顺序;参见 12.6.2).

                  The delete-expression will invoke the destructor (if any) for the object or the elements of the array being deleted. In the case of an array, the elements will be destroyed in order of decreasing address (that is, in reverse order of the completion of their constructor; see 12.6.2).

                  因此,如果您的 std::vector 对象的分配器使用 delete[] 那么,是的,它必然会以相反的顺序销毁元素.

                  So if your std::vector object's allocator uses delete[] then, yes, it is bound to destroy elements in reverse order.

                  但是,不能保证您的 std::vector 会以这种方式工作(事实上,它很可能不会),而且我找不到任何特定于容器.

                  However, there is no guarantee that your std::vector will work this way (and, in fact, it most likely does not), and I can't find any citations specific to the container.

                  真的,我认为这完全取决于您的分配器,而 2003:20.1.5(列出了对分配器的要求)似乎对此没有任何说明.

                  Really, I think it's all down to your allocator and 2003:20.1.5 (which lists the requirements placed upon allocators) doesn't appear to say anything about it.

                  这篇关于std::vector 元素的销毁顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                  <legend id='P1IFU'><style id='P1IFU'><dir id='P1IFU'><q id='P1IFU'></q></dir></style></legend>
                      <tbody id='P1IFU'></tbody>
                  1. <i id='P1IFU'><tr id='P1IFU'><dt id='P1IFU'><q id='P1IFU'><span id='P1IFU'><b id='P1IFU'><form id='P1IFU'><ins id='P1IFU'></ins><ul id='P1IFU'></ul><sub id='P1IFU'></sub></form><legend id='P1IFU'></legend><bdo id='P1IFU'><pre id='P1IFU'><center id='P1IFU'></center></pre></bdo></b><th id='P1IFU'></th></span></q></dt></tr></i><div id='P1IFU'><tfoot id='P1IFU'></tfoot><dl id='P1IFU'><fieldset id='P1IFU'></fieldset></dl></div>

                    <small id='P1IFU'></small><noframes id='P1IFU'>

                  2. <tfoot id='P1IFU'></tfoot>
                    • <bdo id='P1IFU'></bdo><ul id='P1IFU'></ul>