errors with a map of pointers to vectors of pointers
<p>This one is gonna sting a little bit :\ . This is my map declaration:</p>

<pre><code>std::map&lt;std::string, std::shared_ptr&lt;std::vector&lt;std::shared_ptr&lt;BaseEntity&gt; &gt; &gt; &gt; m_EntityByClassList;
</code></pre>

<p>really, the only reason it's so long is because of the smart pointer declarations, it's pretty much just this:</p>

<pre><code>std::map&lt;std::string, std::vector&lt;BaseEntity *&gt; *&gt; m_EntityByClassList;
</code></pre>

<p>still painful to read though. here's my problem. When i try to insert an object into a new vector in the map, i get an "access violation trying to read" runtime error.</p>

<p>the chunk of code that yields this error is this, </p>

<pre><code>for(;;)
    {
        file &gt;&gt; classname;
        if(file.eof())
            break;
        m_EntityList.push_back( m_factory.createInstance(classname));
        m_EntityList.back()-&gt;Initialize();
        m_EntityList.back()-&gt;GetParams(file);
        m_EntityByNameList[m_EntityList.back()-&gt;GetName()] = m_EntityList.back();
        m_EntityByClassList[classname]-&gt;push_back(m_EntityList.back());
    }
</code></pre>

<p>now yes, there is certaintly alot of code i am omitting here, mainly because theres a good 35 or 36 objects and files that go into this blurb here so i'm just going to list off the things relevant. file is an <code>std::ifstream</code> to an open file, classname is an <code>std::string</code>, m_EntityList is a <code>std::vector&lt;std::shared_ptr&lt;BaseEntity&gt; &gt;</code> (shouldn't matter), m_EntityByNameList is a map with indices type <code>std::string</code> and objects type <code>std::shared_ptr&lt;BaseEntity&gt;</code> (also shouldn't matter) and then the map above. all the statements above the last one work exactly correct with verfied results. If the last line is omitted, it compiles and works just dandy.</p>

<p>So this question has nothing to do with the rest of the files, and is only about trying to add a vector to a map and add objects to it. If you feel you need anything else, ask and i'll see about getting it posted up here. Posting everything would easily be 4000-4500 lines.</p>

<p>Annnnyway, what i've learned about maps from <a href="http://www.cplusplus.com/reference/stl/map/operator%5B%5D/" rel="nofollow">this</a> is that using the [ ] operator with an indice that has yet to exist will have one created for you along with a default constructed object at that index. So what i get from this is that an <code>std::shared_ptr&lt;std::vector&lt;std::shared_ptr&lt;BaseEntity&gt; &gt; &gt;</code> will be created at the index classname which means i should be able to access the vector whether it had been created beforehand or just before. So does anyone have any clue what's up?</p>
