title: No matching function for call to 'std::vector<int>::insert' when using a macro
body: <p>I wrote a code which performs some operation on vectors, in which I have defined a macro:</p>
  
  <pre><code>#define all(c) ((c).begin(),(c).end())
  </code></pre>
  
  <p>...and used that macro for vector insertion using <code>v2.insert(1, all(v1))</code>.</p>
  
  <p>This means that I want to insert all elements from vector <code>v1</code> at the second position in vector <code>v2</code>. But, I am getting the following error on the line with the <code>insert</code> function call: </p>
  
  <blockquote>
    <p>no matching function for call to 'std::vector::insert...</p>
  </blockquote>
  
  <p>The code is as follows:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;stdio.h&gt;
  #include&lt;vector&gt;
  #include&lt;stdlib.h&gt;
  
  #define all(c) ((c).begin(),(c).end())
  using namespace std;
  int main()
  {
      int data[]={1,2,3,4,5,6,7,8};
      vector&lt;int&gt; v1(data+1,data+5);
      vector&lt;int&gt; v2(2,1);
  
      v2.insert(1,all(v1));
  
      printf("\n Before the for loop");
      for(vector&lt;int&gt; v2::iterator it=v2.begin();it!=v2.end();it++)
      {
          printf("\t %d \t ",*it++);
      }
      return 0;
  }
  </code></pre>