Possible duplicate:Are short-circuiting boolean operators provided for in C / C ++? And the evaluation procedure?
Is there any standard order or mathematical order for extracting Boolean sentences? For instance:
if (firstTrue && secondTrue) { }
Can you be sure that firstTrue will be checked first?
Yes. &&and || short circuit operators . The order in which operands are evaluated is clearly defined (from left to right).
&&
||
&&also a point of sequence.Therefore, writing is if( ++i && i) { }excellent.
if( ++i && i) { }
ISO C ++ 03 ( 5.14/1) says:
5.14/1
& & . bool ( 4). , false . && & : , .
EDIT: ( )
ISO ++ 03 ( 1.9/18)
1.9/18
a &&a ||a? b: ca, b(5.14, 5.15, 5.16, 5.18), .
(5.14, 5.15, 5.16, 5.18), .
firstTrue. , firstTrue , True . .
: http://en.wikipedia.org/wiki/Short-circuit_evaluation
||. || true, .
. "" ( )
&& ( ||) : , . LHS RHS. RHS, LHS. ( , ), .
&& ||. && || .
Source: https://habr.com/ru/post/1766553/More articles:named routes with design in Rails 3 haml view - ruby | fooobar.comhow to check if Vista or XP user is working - vb.netCan browsers connect to the proxy server via SSL / TLS? - browserSleeping cascade versus manual removal - hibernateEnable drag-and-drop from Explorer to Run as Administrator - c #Тестирование метода Webservice в Visual Studio: почему он говорит, что он успешно выполняется без запуска теста и теста? - c#Where does the stack memory allocated to the stream come from? - garbage-collectionReading a line from a serial port is blocked - c #Ruby or regex to break redundant lines - ruby | fooobar.comRails 3 - including JavaScript in a view? - javascriptAll Articles