1

When given an expression of the form

a ? b : c

what is its type? Can the types of b and c differ and the expression still be valid? If so, what are the rules on what the type of the expression is. What rules are there for rvalue- and lvalue-ness?

Ralph Tandetzky
  • 22,780
  • 11
  • 73
  • 120
  • I don't know if it is true in general, but [Microsoft has an MSDN article detailing the rules](https://msdn.microsoft.com/en-us/library/e4213hs1.aspx) – Guvante Mar 20 '15 at 21:32
  • The scope of the question http://stackoverflow.com/questions/8535226/return-type-of-ternary-conditional-operator is much narrower than mine. Even though it is a good link, the answers there, do not fully answer my question. – Ralph Tandetzky Mar 20 '15 at 21:39
  • The answers do indeed fully answer your question. Several yards of the standard are quoted. – user207421 Mar 20 '15 at 22:10
  • 1
    @EJP None of them have a quote from the C++11 standard though. The yards of quotes are from N1905, a 2005 working draft. That said, [expr.cond] is 1.5 pages long, so I'm not really inclined to quote it again... – T.C. Mar 20 '15 at 22:21
  • @T.C. Did it change in C++11? – user207421 Mar 20 '15 at 22:48
  • 1
    @EJP Yes, that section changed in the last 10 years. – T.C. Mar 20 '15 at 22:49

0 Answers0