I\'d like to use the indices trick to eliminate for
loops in my C++11 program (similar to forced -funroll-loops
).
Here\'s an example:
Try this ( http://liveworkspace.org/code/e65a81d0d3e9b17692713fd3e9d681f5 ):
template struct indices {};
template struct indices_gen
: indices_gen
{};
template struct indices_gen : indices
{};
Working example: http://liveworkspace.org/code/3d0ba21cc637a61c3e63d2db002f87af
Edit : Check Xeo's comment. Above example don't check if S < E
, so it can go bad if you make a mistake. This (Xeo's code) will return a compiler error in such case: http://liveworkspace.org/code/81205e13334e89537bdc0b79b3ba56fc