Question: I can clearly do something like this:

```
for(int i = 0; i < 10000; i++)
    testIteration();

```

But is there any std functions which does similar thing in one line? Something like that:

```
std::repeat(10000, testIteration);

```

Answer: 
I personally like to use a small helper function to do this.

```
template <typename F>
void repeat(size_t n, F f) {
  while (n--) f();
}

int main() {

   repeat(1000, [&] {
      testIteration();
   });
}

```

This avoids having to spell out the name of a variable. I prefer using view::iota when I need a name though. 

That being said, I'm told this is confusing to read, and everyone *can* read a for loop, so that's probably the way to go. (Unless the function is put in std:: of course).
What about simply defining a macro?
`#define FOR(N, foo, ...) for (int _i = 0; _i < N; _i++) foo(__VA_ARGS__);`

For eg. 

```
#include <iostream>

#define FOR(N, foo, ...) for (int _i = 0; _i < N; _i++) foo(__VA_ARGS__);

void bar(int a, int b)
{
    std::cout << "hello " << a+b << std::endl;
}

int main()
{
    FOR(5, bar, 12, 6);
    return 0;
}

```

Output:

```
hello 18
hello 18
hello 18
hello 18
hello 18

```