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

    <bdo id='u1Loa'></bdo><ul id='u1Loa'></ul>
  • <legend id='u1Loa'><style id='u1Loa'><dir id='u1Loa'><q id='u1Loa'></q></dir></style></legend>

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

        声明多维 std::array 的不那么冗长的方法

        时间:2023-09-15

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

              • <bdo id='4zZbz'></bdo><ul id='4zZbz'></ul>
                <tfoot id='4zZbz'></tfoot>

                <small id='4zZbz'></small><noframes id='4zZbz'>

                <legend id='4zZbz'><style id='4zZbz'><dir id='4zZbz'><q id='4zZbz'></q></dir></style></legend>

                  本文介绍了声明多维 std::array 的不那么冗长的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  简短的问题:有没有更短的方法来做到这一点

                  Short question: Is there a shorter way to do this

                  array<array<atomic<int>,n>,m> matrix;
                  

                  我希望像

                  array< atomic< int>,n,m> matrix;    
                  

                  但它不起作用...

                  推荐答案

                  嵌套时,std::array 会变得非常难以阅读并且变得冗长.维度的相反顺序可能特别令人困惑.

                  When nested, std::array can become very hard to read and unnecessarily verbose. The opposite ordering of the dimensions can be especially confusing.

                  例如:

                  std::array < std::array <int, 3 > , 5 > arr1; 
                  

                  对比

                  char c_arr [5][3]; 
                  

                  另外,注意当你嵌套 std::array 时,begin()、end() 和 size() 都返回无意义的值.

                  Also, note that begin(), end() and size() all return meaningless values when you nest std::array.

                  出于这些原因,我创建了自己的固定大小的多维数组容器,array_2d 和 array_3d.他们的优势是可以使用 C++98.

                  For these reasons I've created my own fixed size multidimensional array containers, array_2d and array_3d. They have the advantage that they work with C++98.

                  它们类似于 std::array,但适用于 2 维和 3 维多维数组.它们比内置多维数组更安全,性能也不差.我没有包含维度大于 3 的多维数组的容器,因为它们不常见.在 C++11 中,可以制作支持任意维数的可变参数模板版本(类似于 Michael Price 的示例).

                  They are analogous to std::array but for multidimensional arrays of 2 and 3 dimensions. They are safer and have no worse performance than built-in multidimensional arrays. I didn't include a container for multidimensional arrays with dimensions greater than 3 as they are uncommon. In C++11 a variadic template version could be made which supports an arbitrary number of dimensions (Something like Michael Price's example).

                  二维变体的一个例子:

                  //Create an array 3 x 5 (Notice the extra pair of braces) 
                  fsma::array_2d <double, 3, 5> my2darr = {{ 
                  { 32.19, 47.29, 31.99, 19.11, 11.19}, 
                  { 11.29, 22.49, 33.47, 17.29, 5.01 }, 
                  { 41.97, 22.09, 9.76, 22.55, 6.22 } 
                  }};  
                  

                  此处提供完整文档:http://fsma.googlecode.com/files/fsma.html

                  您可以在此处下载库:http://fsma.googlecode.com/files/fsma.zip

                  这篇关于声明多维 std::array 的不那么冗长的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:二维数组值 C++ 下一篇:如果明确给出多维数组,为什么 char[][] = {{...},

                  相关文章

                  最新文章

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

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

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

                    2. <tfoot id='UvYii'></tfoot>