To quickly create a for loop similar to python's for i in range(100)
, I could do:
for (auto const i : std::views::iota(0, 100))
{ /* ... */ }
However, CLion is warning me to add a std::weakly_incrementable
constraint to my auto
:
for (std::weakly_incrementable auto const i : std::views::iota(0, 100))
{ /* ... */ }
I know that the starting value of iota_view
must be weakly_incrementable
, and I would assume that auto i
will create an i
that is the same type of the starting value.
But is it true? Is it possible for it to create something of a totally different type (not even weakly incrementable)? And can I safely ignore the warning?