I have a C++ snippet below with a run-time for loop,
for
for(int i = 0; i < I; i++) for (int j = 0; j < J; j++) A( row(i,j), column(i,j)
You could use Boost MPL.
An example of loop unrolling is on this mpl::for_each page.
for_each< range_c >( value_printer() );
It doesn't seem that it's all evaluated at compile time, but it may be a good starting point.