I\'ve been debugging a program for some time, and eventually found the error was due to a reference not being updated as I thought it would be.
Here\'s a example that sh
There's no guarantee in C++ about the order in which function arguments in a single expression are evaluated, not even when these functions are chained method calls. You are invoking undefined behavior here and that's what you get.
The . operator does imply sequencing, but only insofar that the expression before the . has to be fully evaluated before the member is accessed. It doesn't mean that the evaluations of subexpressions are suspended until that point.
Also, don't pass int
s by const int&
, there's no way this could be faster than passing an int
directly (unless for some strange reason int
doesn't fit into a processor word and the reference does).