title: How is std::map overloading its subscript [] operator ? C++
body: <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;map&gt;
  int main(void) {
    std::map&lt;char, int&gt; mapint;
  
    mapint.insert({'a', 1});
    mapint.insert({'b', 2});
  
    // subscript operator is overloaded to return iterator.second (the value with key 'a')
    int ex = mapint['a'];
    std::cout &lt;&lt; ex &lt;&lt; std::endl;
    // Why does this NOT traslate to 1=10 ?
    // instead it replaces or creates pair &lt;'a',10&gt;...
    mapint['a'] = 10;
  
    for (auto i : mapint) {
      std::cout &lt;&lt; i.first &lt;&lt; &quot;,&quot; &lt;&lt; i.second &lt;&lt; std::endl;
    }
    
    // OUTPUT
  // 1
  // a,10
  // b,2
  
    return 0;
  }
  </code></pre>
  <p>How is the <code>map</code> operator being overloaded? I tried looking at the code for map but i couldn't find anything to answer my question...
  I want to make something similar for one of my classes and i think figuring this out should help alot!</p>