Order of evaluation of arguments using std::cout

前端 未结 5 1107
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 13:26

Hi all I stumbled upon this piece of code today and I am confused as to what exactly happens and more particular in what order :

Code :

#include &l         


        
5条回答
  •  无人共我
    2020-11-22 14:14

    The evaluation order of elements in an expression is unspecified (except some very particular cases, such as the && and || operators and the ternary operator, which introduce sequence points); so, it's not guaranteed that test will be evaluated before or after foo(test) (which modifies it).

    If your code relies on a particular order of evaluation the simplest method to obtain it is to split your expression in several separated statements.

提交回复
热议问题