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

      <small id='1avwG'></small><noframes id='1avwG'>

      • <bdo id='1avwG'></bdo><ul id='1avwG'></ul>
      <tfoot id='1avwG'></tfoot>

    2. 如何遍历 boost::multi_array

      时间:2023-09-15

    3. <tfoot id='eSO2t'></tfoot>
        <tbody id='eSO2t'></tbody>
        • <bdo id='eSO2t'></bdo><ul id='eSO2t'></ul>

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

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

                本文介绍了如何遍历 boost::multi_array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我一直在研究 boost::multi_array 库,以寻找允许您在单个 for 循环中遍历整个 multi_array 的迭代器.

                I have been looking into the boost::multi_array library in search of an iterator that allows you to traverse the whole multi_array in a single for loop.

                我认为那个库中没有这样的迭代器.(在那里找到的迭代器可以让你遍历 multi_array 的一个维度)

                I don't think there is any such iterator in that library. (The iterators that are found there let you traverse a single dimension of the multi_array)

                我错了吗?
                如果没有,是否有任何库定义了这样的迭代器?

                Am I wrong?
                If not, is there any library that defines such an iterator?

                进入细节,我想写一些类似的东西:

                Entering into details, I'd like to write something like:

                boost::multi_array< double, 3 > ma(boost::extents[3][4][2]);  
                
                for( my_iterator it = ma.begin(); it != ma.end(); ++it )  
                {  
                    // do something  
                    // here *it has element type (in this case double)  
                }  
                

                并获得重复 3x4x2 次的循环

                and obtain a loop that repeats 3x4x2 times

                推荐答案

                您可以使用 中的 std::for_each 实现来访问每个人元素.Boost 文档

                You can use an implementation of std::for_each from <algorithm> to access each individual element. There is an example in the Boost documentation

                或者,您可以使用 array::origin()array::num_elements() 如下:

                Alternatively, you can use array::origin() and array::num_elements() as follows:

                boost::multi_array< double, 3 > ma(boost::extents[3][4][2]);  
                
                for(auto i = ma.origin(); i < (ma.origin() + ma.num_elements()); ++i)  
                {  
                    // do something with i
                }  
                

                这篇关于如何遍历 boost::multi_array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如果明确给出多维数组,为什么 char[][] = {{...}, 下一篇:初始化指向多维数组的动态指针的正确方法?

                相关文章

                最新文章

              • <small id='CUGcH'></small><noframes id='CUGcH'>

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

                  • <bdo id='CUGcH'></bdo><ul id='CUGcH'></ul>
                1. <tfoot id='CUGcH'></tfoot>