c++ - what does - if(1, true) - mean? -


i came across code:

if (1, true) {/*...*/} 

what mean? while evaluates true:

void foo(){} ... if(1, foo()) {/*...*/} 

this doesnt compile:

void foo(){} ... if (1 == foo()) {/*...*/} 

obviously because compiler expects foo() return integral value. thought comma translates operator. comma in if clause translate internally?

the comma operator evaluates left operand, followed right operand. expression like

(1, true) 

evaluates 1 first, true, resulting in expression value of true.

in particular case, use of comma operator seems rather pointless.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -