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: 
Just for a reference, there is `std::generate` and `std::generate_n` which can be used, but only for array initialization by doing something like this:

```
int i = 0;
std::generate_n(myArray, 10000, [&]() -> int { return i++; });

```
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

```