If (VEC. End () = Vec. Erase (VEC. Begin (), VEC. End () <br/>
According to the definition of msdn and Vc, this expression must be true,
Because VC calculates erase (right expression) First, the returned value must be end, and then end () is calculated. The returned value is the same as the returned value of erase.
However, in fact
Debug version execution is true
Release Version execution isFalse!
In the release version, VEC. End () is optimized to be a value obtained first, and then erase is calculated,
Erase will change the end value.
Therefore, the release version must be written in this way:
Iter = Vec. erase (VEC. begin (), VEC. end () <br/> // The above forces the calculation of erase first <br/> If (VEC. end () = ITER) // The end () value is equal. <br/>
The first statement made two serious mistakes:
1. incorrect assumptions based on experienceCalculate the value of the expression from right to left during logical operations (C ++ is not specified and may be optimized)
2. The end () return value is a constant.