On the this page on the en.cppreference page, there are examples of possible lexicographic comparisons. Here is the main 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 such as (void)some_argument; are commonly used to suppress compiler warnings about unused parameters. But in this function, all parameters, including first2, are used by - , so what is the write point (void) first2++ in the for?
Is this some syntax workaround in case of overloading the InputIt1 operator, ,?
c ++ expression
Xeverous
source share