title: c++: Reason of "No instance of overloaded function"
body: <p>I am trying to sort a vector of arrays using &quot;Insertion sort&quot; method.
  But I am facing error shown at the bottom referring to these two lines:</p>
  <pre><code>vec.insert(j , vec[i]);
  
  vec.erase(i+1);
  </code></pre>
  <p>complete code:</p>
  <pre><code>
  #include&lt;iostream&gt;
  #include&lt;vector&gt;
  
  /*
  I could do it recursively
  */
  void ins_sort(std::vector&lt;int&gt; vec );
  
  int main(){
  
  std::vector&lt;int&gt; vec = {2 , 8 , 5 , 3 , 9 , 4};
  
  ins_sort(vec);
  
  }
  
  void ins_sort(std::vector&lt;int&gt; vec ){
  
      for (int i = 1 ; i &lt; vec.size() ; i++){
  
          if(vec[i] &lt; vec[i-1]){ //look for a index which value is lower than vec[i], then move vec i to the index after that
  
              for (int j = 0 ; j &lt;vec.size() ; j++){
  
                  if (vec[i] &lt; vec[j] ){
  
                      vec.insert(j , vec[i]);//inserting vec[i] into the right position
  
                      vec.erase(i+1); //erasing vec[i] which now is vec[i+1] after insertion
  
                      break; //ending the inner loop after finding the first greater value
                  }
              }
  
          }
      }
  }
  </code></pre>
  <p>error:
  <a href="https://i.stack.imgur.com/1Spzn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Spzn.png" alt="enter image description here" /></a></p>
  <p>I checked syntax of inserting a vector and erasing from that, but it looks fine. I am not sure why getting this error.</p>
  <p>Update: It got corrected by adding &quot;vec.begin() &quot; to the address of index as below:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  
  /*
  I could do it recursively
  */
  void ins_sort(std::vector&lt;int&gt; vec );
  
  int main(){
  
  std::vector&lt;int&gt; vec = {2 , 8 , 5 , 3 , 9 , 4};
  
  ins_sort(vec);
  
  
  
  }
  
  void ins_sort(std::vector&lt;int&gt; vec ){
  
      for (int i = 1 ; i &lt; vec.size() ; i++){
  
          if(vec[i] &lt; vec[i-1]){ //look for a index which value is lower than vec[i], then move vec i to the index after that
  
              for (int j = 0 ; j &lt;vec.size() ; j++){
  
                  if (vec[i] &lt; vec[j] ){
  
                      vec.insert(vec.begin() + j , vec[i]);//inserting vec[i] into the right position
  
                      vec.erase(vec.begin() + i + 1); //erasing vec[i] which now is vec[i+1] after insertion
  
                      break; //ending the inner loop after finding the first greater value
                  }
              }
  
          }
      
      }
    for (int i = 0 ; i &lt; vec.size() ; i++){
  
      std::cout&lt;&lt;vec[i];  
  }
  }
  </code></pre>