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: 
In the [proposed standard for C++20](http://eel.is/c++draft/range.iota) there is an example for `iota_view`:

```
for (int i : iota_view{1, 10})
  cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9

```

But for now, [range-v3](https://github.com/ericniebler/range-v3) library can be used:

```
for (int _ : view::iota{0, 10})
    testIteration();            // calls testIteration 10 times.

```
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); _--) {}

```