3 ms·
I think that when you overload the comma operator in C++, you change the nature of the sequence point. I believe you're no longer guaranteed to have "1, 2, 3" e
by jerryr 15y ago
I think that when you overload the comma operator in C++, you change the nature of the sequence point. I believe you're no longer guaranteed to have "1, 2, 3" evaluated in that order. In your example, this doesn't matter, but if it was "f1(), f2(), f3()" and for some reason the sequence of those calls determined what each returned, you might have a problem. I could be wrong here though--my C++ is rusty from years of disuse.
- bobbyi 15y agoItem #7 in More Effective C++ is to "never overload &&, || or ," because it changes the order of evaluation (with the boolean logic operators, it changes because the usual short-circuiting behavior is gone since the second argument has to be evaluated to pass it as an argument).