Can sombody explain how this works?
int x, y;
....
(some_condition ? x : y) = 100;
Is this intended to work or is is just a “blind” translation or the compiler (something like vec[10] equals 10[vec])?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is valid C++ and invalid C.
The result of a conditional expression can be (and in this case is) an lvalue in C++ refering to one of
xorydepending on whethersome_conditionevaluates totrue. In C++ eitherxis assigned the value 100 if some_condition istruewhen converted to abool, otherwiseyis assigned 100.In C, the result of a conditional expression is never an lvalue and cannot be assigned to.