title: Can I assign a value to a conditional expression in C++?
body: <p>Is it valid to simplify this...</p>
  
  <pre class="lang-c++ prettyprint-override"><code>if (bool_b) {
      int_i1 = int_i3;
  } else {
      int_i2 = int_i3;
  }
  </code></pre>
  
  <p>..into the following?</p>
  
  <pre class="lang-c++ prettyprint-override"><code>(bool_b ? int_i1 : int_i2) = int_i3;
  </code></pre>
  
  <p>It seems to work on my compiler. But I think the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf" rel="nofollow">draft C++11 standard: N3337</a> says it's invalid:</p>
  
  <blockquote>
    <ul>
    <li>conditional-expression:
    <ul>
    <li>logical-or-expression</li>
    <li>logical-or-expression ? expression : assignment-expression</li>
    </ul></li>
    <li>assignment-expression:
    <ul>
    <li>conditional-expression</li>
    <li>logical-or-expression assignment-operator initializer-clause</li>
    <li>throw-expression</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>If I understand it well, the part at the left of <code>=</code> should be a <em>logical-or-expression</em>. But even though <em>logical-or-expression</em> are <em>conditional-expression</em>s, the reciprocal is false.</p>