C++/STL: std::transform with given stride?

后端 未结 4 761
既然无缘
既然无缘 2021-01-12 17:53

I have a 1d array containing Nd data, I would like to effectively traverse on it with std::transform or std::for_each.

unigned int nelems;
unsigned int strid         


        
4条回答
  •  广开言路
    2021-01-12 18:45

    This is terrible, people told you to use stride iterators instead. Apart from not being able to use functional objects from standard library with this approach, you make it very, very complicated for compiler to produce multicore or sse optimization by using crutches like this. Look for "stride iterator" for proper solution, for example in c++ cookbook.

    And back to original question... use valarray and stride to simulate multidimensional arrays.

提交回复
热议问题