Why does std::transform and similar cast the 'for' loop increment to (void)?

It is possible to overload operator,. Casting either operand to void prevents any overloaded operator from being called, since overloaded operators cannot take void parameters.


It avoids call of overloaded operator, if there is any. Because the type void can't be an argument of a function (operator).

Another approach would be inserting void() in the middle:

++__first, void(), ++__result