On this page of en.cppreference there are examples of possible implementation of lexicographical comparison. Here is the basic one:
template<class InputIt1, class InputIt2>
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2)
{
for ( ; (first1 != last1) && (first2 != last2); first1++, (void) first2++ ) {
if (*first1 < *first2) return true;
if (*first2 < *first1) return false;
}
return (first1 == last1) && (first2 != last2);
}
IIRC lines like (void)some_argument;
are commonly used to supress compiler warnings about unused parameters. But in this function, all parameters, including first2 are used - so what's the point of writing (void) first2++
in the for statement?
Is it some syntax workaround in case InputIt1 overloads operator,
?