title: inserting values of vector into unordered map
body: <p>I am trying to insert the values present in a vector into a unordered_map. I passed the vector to another function and declare an unordered_map and an iterator to the vector. But while compiling it gives error(below). I would like to understand why does this fail. Searching online has given me a rough idea as to what might be wrong but it is not clear to me:<br>
  1. When i pass the vector without '&amp;', a copy of the vector is sent to the function. What does this exactly mean? How does this works internally?<br>
  2. What kind of values does make_pair take? Shouldn't 'n' and '*it' just be simple numerical values that make_pair should accept?</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;unordered_map&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  
  void readValues(vector&lt;int&gt;&amp;v, int n)
  {
      int temp;
      while(n--)
      {
          cin&gt;&gt;temp;
          v.push_back(temp);
      }
  }
  
  unordered_map&lt;int, int&gt; storeinhashmap(vector&lt;int&gt;v, int n)
  {
      vector&lt;int&gt;::iterator it=v.begin();
      unordered_map&lt;int,int&gt;h;
      int temp;
      while(n--)
      {
          temp = *it;
          //cout&lt;&lt;"iter "&lt;&lt;*it&lt;&lt;" "&lt;&lt;++n&lt;&lt;endl;
          h.insert(make_pair&lt;int,int&gt;(n, *it));
          it++;
      }
      return h;
  }
  
  
  
  int main()
  {
      int t;
      cin&gt;&gt;t;
      while(t--)
      {
          int n, x;
          cin&gt;&gt;n;
          vector&lt;int&gt;v;
          readValues(v, n);
          cin&gt;&gt;x;
          unordered_map&lt;int, int&gt;h = storeinhashmap(v, n);
          //char ans = checksumisx(h, n);
  
      }
      return 0;
  }
  </code></pre>
  
  <p>Error -</p>
  
  <pre><code>harshit@harshit-5570:~/Desktop/geeksforgeeks$ g++ -std=c++14 key_pair.cpp 
  key_pair.cpp: In function ‘std::unordered_map&lt;int, int&gt; storeinhashmap(std::vector&lt;int&gt;, int)’:
  key_pair.cpp:26:43: error: no matching function for call to ‘make_pair(int&amp;, int&amp;)’
           h.insert(make_pair&lt;int,int&gt;(n, *it));
                                             ^
  In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                   from /usr/include/c++/5/bits/char_traits.h:39,
                   from /usr/include/c++/5/ios:40,
                   from /usr/include/c++/5/ostream:38,
                   from /usr/include/c++/5/iostream:39,
                   from key_pair.cpp:1:
  /usr/include/c++/5/bits/stl_pair.h:276:5: note: candidate: template&lt;class _T1, class _T2&gt; constexpr std::pair&lt;typename std::__decay_and_strip&lt;_Tp&gt;::__type, typename std::__decay_and_strip&lt;_T2&gt;::__type&gt; std::make_pair(_T1&amp;&amp;, _T2&amp;&amp;)
       make_pair(_T1&amp;&amp; __x, _T2&amp;&amp; __y)
       ^
  /usr/include/c++/5/bits/stl_pair.h:276:5: note:   template argument deduction/substitution failed:
  key_pair.cpp:26:43: note:   cannot convert ‘n’ (type ‘int’) to type ‘int&amp;&amp;’
           h.insert(make_pair&lt;int,int&gt;(n, *it));
  </code></pre>