title: Unexpected behavior from ternary operator
body: <p>When I run this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;map&gt;
  
  using namespace std;
  
  void f1() {
      map&lt;int, int&gt; m;
      m[5] = m.find(5) == m.end() ? 1 : 2;
      cout &lt;&lt; m[5] &lt;&lt; endl;
  }
  void f2() {
      map&lt;int, int&gt; m;
      if (m.find(5) == m.end())
          m[5] = 1;
      else
          m[5] = 2;
      cout &lt;&lt; m[5] &lt;&lt; endl;
  }
  int main() {
      f1();
      f2();
      return 0;
  }
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>2
  1
  </code></pre>
  
  <p>Why am I getting wrong output when I am using ternary operator?</p>