<legend id='s1bdS'><style id='s1bdS'><dir id='s1bdS'><q id='s1bdS'></q></dir></style></legend>

    <bdo id='s1bdS'></bdo><ul id='s1bdS'></ul>
  • <tfoot id='s1bdS'></tfoot>

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

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

      1. std::vectors 的 std::vectors 连续性

        时间:2023-09-15
          <bdo id='L3J44'></bdo><ul id='L3J44'></ul>

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

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

                <legend id='L3J44'><style id='L3J44'><dir id='L3J44'><q id='L3J44'></q></dir></style></legend>
                    <tbody id='L3J44'></tbody>
                  本文介绍了std::vectors 的 std::vectors 连续性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我知道 std::vector 在内部连续地存储它的数据(除非它是 std::vector),都在旧的 中>C++03 标准和新的C++11.

                  I know that std::vector<T> internally stores it's data contiguously (unless it is std::vector<bool>) both in the old C++03 standard and the new C++11.

                  处理这个问题并引用标准的不错的 stackoverflow 问题:answer、答案.

                  Nice stackoverflow questions that deal with this and quote the standard: answer, answer.

                  嵌套向量中的数据怎么样 std::vector ;>?它是如何存储的?

                  What about the data inside nested vectors std::vector <std::vector <T> >? How is that stored?

                  如果每个内部向量都需要连续存储它的数据,那么 &v[n] == &v[0] + n for all 0 <= n .

                  If every internal vector needs to store it's data contiguously, how can it be true that &v[n] == &v[0] + n for all 0 <= n < v.size().

                  用稍微不同的话说,是否可以简单地"并顺序地(通过指针或类似物)访问存储在这种嵌套结构中的所有元素一维向量?

                  To phrase this slightly different, is it possible to access all the elements stored in such nested structure "simply" and sequentially (via a pointer or similar) the same way it can be done for a 1-D vector?

                  推荐答案

                  没有.vector 的元素存储在动态分配的内存块中;否则,vector 的容量无法增加.vector 对象只包含一个指向该块的指针.

                  No. The elements of a vector are stored in a dynamically allocated block of memory; otherwise, the capacity of the vector could not increase. The vector object just holds a pointer to that block.

                  元素顺序存储的要求仅适用于元素本身,而不适用于这些元素的任何动态分配的成员.

                  The requirement that the elements be stored sequentially applies only to the elements themselves, and not to any dynamically allocated members of those elements.

                  这篇关于std::vectors 的 std::vectors 连续性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                    1. <legend id='iOqvp'><style id='iOqvp'><dir id='iOqvp'><q id='iOqvp'></q></dir></style></legend>

                        <tbody id='iOqvp'></tbody>
                      <tfoot id='iOqvp'></tfoot>

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

                          <bdo id='iOqvp'></bdo><ul id='iOqvp'></ul>