In C++ I need to iterate a certain number of times, but I don\'t need an iteration variable. For example:
for( int x=0; x<10; ++x ) { /* code goes her
Edit now with 100% fewer loop variables declared.
template void repeat(unsigned n, F f) { while (n--) f(); }
Use it as:
repeat(10, f);
or
repeat(10, [] { f(); });
int g(int); repeat(10, std::bind(g, 42));
See it live at http://ideone.com/4k83TJ