Dimension-independent loop over boost::multi_array?

前端 未结 4 1096
孤独总比滥情好
孤独总比滥情好 2020-12-19 06:00

Say I\'ve got an N-dimensional boost::multi_array (of type int for simplicity), where N is known at compile time but can vary (i.e. is a non-type template param

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 06:49

    If you don't need the index, you can simply do:

      for (unsigned int i = 0; i < A.num_elements(); i++ )
      {
        tValue item = A.data()[i];
        std::cout << item << std::endl;
      }
    

提交回复
热议问题