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).
I know this isn't providing anything new from the above answers except that perhaps that my solution is **very short**. To repeat code *2* times I use a loop like the following:

```
for (auto _{2}; _--;) { /* this code gets repeated twice */ }

```

I think using the prefix operator would be less clear since to repeat code twice the loop would need to be:

```
for (auto _{3}; --_;) { /* this code gets repeated twice */ }

```

Parentheses would also of course work instead of braces, i.e.:

```
for (auto _(2); _--) {}

```