C++ Debug Assertion Failed Vector Subscript out of range : <p>i've got some code that i've written using a 2d vector instead of a 2d array however when i go to run it all it says is "vector subscript out of range". any help is appreciated.</p>

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

using namespace std;

int mapx, mapy = 5;

vector&lt;vector&lt;int&gt;&gt; map(mapx, vector&lt;int&gt; (mapy, 0));

int i, x;

int main(){

for (i = 0; i &lt; map.size(); i++){
    for (x = 0; x &lt; map[i].size(); x++)
    {
        map[i][x] = i + x;
    }
}

cout &lt;&lt; map[0][0];

cin &gt;&gt; i;
return 0;
}
</code></pre>
