I was reading the "C++ 17 Completed Guide" by Nicolai Josuttis and came across the following expression:
foo(arg1), (foo(arg2), foo(arg3));
The author claims that the evaluation order will be left to right for the built-in comma operators, but it can be changed by overloading them. However, I saw the "Order of evaluation" article on cppreference (https://en.cppreference.com/w/cpp/language/eval_order) and came across the following statements:
- Every value computation and side effect of the first (left) argument of the built-in comma operator , is sequenced before every value computation and side effect of the second (right) argument.
and
- Every overloaded operator obeys the sequencing rules of the built-in operator it overloads when called using operator notation.
So, according to the statement 16, it appears that cppreference claims the overloaded comma operator to have the same evaluation order as its built-in counterpart. So, what exactly did the author mean by saying that "by overloading the comma operator, you can change its evaluation order" and what exactly behavior is expected?