title: map insert with pair type
body: <p>While inserting an element in a map of type <code>&lt;int,int&gt;</code> , we have to explicitly mention the types again as pair. Isnt is redundant?</p>
  
  <pre><code>map&lt;int,int&gt; m1;
  //m1.insert(1,1); //NOT OK since the pair type &lt;int,int&gt; not mentioned
  m1.insert(pair&lt;int,int&gt;(1,1)); //OK
  </code></pre>
  
  <p>m1 is declared as <code>&lt;int,int&gt;</code>. Would there be any instance wherein we try to insert any element other than <code>&lt;int,int&gt;</code>  <code>e.g. m1.insert(pair&lt;int,string&gt;(1,"boo"))</code> ? If no, then isn't it redundant to write <code>&lt;int,int&gt;</code> again while inserting an element?</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>To explain in detail here is a small example:</p>
  
  <pre><code>template&lt;typename T1,typename T2&gt;
  class Test
  {
  public:
      template&lt;typename T1&gt;
      void fun1()
      {
          cout&lt;&lt;"This is called for T1 templatized fun1"&lt;&lt;endl;
      }
      template &lt;typename T1,typename T2&gt;
      void insert(pair&lt;T1,T2&gt; &amp;obj)
      {
          cout&lt;&lt;obj.first&lt;&lt;" "&lt;&lt;obj.second&lt;&lt;endl;     
      }
  };
  
  int main()
  {
      Test &lt;int,int&gt;obj; // Even though i have declared obj as type int,int, i am still able to call insert on type int,string
      obj.insert(pair&lt;int,string&gt;(1,"Anurag"));
  </code></pre>
  
  <p>Here we clearly see that the types with which i created object <em>obj</em> is different than the types with which i called <em>insert()</em> .
  But i dont understand how would the member function map::insert() make sure that the types are same as those with which the object is created?
  One way that i thought of was:</p>
  
  <pre><code>template &lt;typename T3=T1,typename T4=T2&gt; //where T1 and T2 are class typenames
  void insert2(pair&lt;T3,T4&gt;&amp; obj2)
  {
      cout&lt;&lt;"Inside insert2 \n";
  }
  </code></pre>
  
  <p>But even this would not be allowed since this is a function template not a class template. I tried looking inside the header file of <strong>map</strong> to see the declaration of insert but got more confused.</p>