title: Why and when does the ternary operator return an lvalue?
body: <p>For a long time I thought that the ternary operator always returns an rvalue. But to my surprise it doesn't. In the following code I don't see the difference between the return value of <code>foo</code> and the return value of the ternary operator.</p>
  
  <pre><code>#include &lt;iostream&gt;
  int g = 20 ;
  
  int foo()
  {
      return g ;
  }
  
  int main()
  {
      int i= 2,j =10 ;
  
      foo()=10 ; // not Ok 
      ((i &lt; 3) ? i : j) = 7; //Ok
      std::cout &lt;&lt; i &lt;&lt;","&lt;&lt;j &lt;&lt; "," &lt;&lt;g &lt;&lt; std::endl ;
  }
  </code></pre>