Template-ing a 'for' loop in C++?

后端 未结 10 642
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 12:58

I have a C++ snippet below with a run-time for loop,

for(int i = 0; i < I; i++)
  for (int j = 0; j < J; j++)
    A( row(i,j), column(i,j)         


        
10条回答
  •  天涯浪人
    2020-12-25 13:25

    I've never tried to do this so take this idea with a grain of salt...

    It seems like you could use Boost.Preprocessor to do the loop unrolling (specifically the BOOST_PP_FOR and BOOST_PP_FOR_r macros) and then use templates to generate the actual constant expression.

提交回复
热议问题