C++ Error: no matching function for call to 'std::vector<int>::swap(std::vector<int>)'
<p>I was reading a blog about std::vector. See the <strong>Swapping contents</strong> section in this <a href="http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c4027/C-Tutorial-A-Beginners-Guide-to-stdvector-Part-1.htm" rel="nofollow">website</a>.</p>

<hr>

<p>Basically, it says a common application of <code>swap()</code> method is forcing a vector to release the memory it holds. But after I ran the code below, I got the error <code>Error: no matching function for call to 'std::vector&lt;int&gt;::swap(std::vector&lt;int&gt;)'|</code>. Where has gone wrong?</p>

<hr>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

int main( )
{
    std::vector&lt;int&gt; v;
    v.push_back(1); v.push_back(2);
    v.clear();
    v.swap(std::vector&lt;int&gt;(v));
    return 0;
}
</code></pre>