title: Does std::map need to be initialized?
body: <p>I have a singleton, that is an image manager. When I try to load an image, I call singleton in this way:</p>
  
  <pre><code>utils::CImageBuff* img4 = utils::CImageManager::getInstance()-&gt;loadFromFile("uswg.png");
  </code></pre>
  
  <p>And, into loadFromFile method, I store the image into a map:</p>
  
  <pre><code>m_imageMap[imageHashID].setHeight(ilGetInteger(IL_IMAGE_HEIGHT));
  m_imageMap[imageHashID].setWitdh(ilGetInteger(IL_IMAGE_WIDTH));
  m_imageMap[imageHashID].setBpp(ilGetInteger(IL_IMAGE_BPP));
  ....
  </code></pre>
  
  <p>The problem is that I get a mem access error. Is like if m_imageMap is NULL o wrong initialized, because excepttion is thrown in the first sentence. But as I said, is a singleton so the map must me initialized. I'm developing in VC++ 2008. It could be a wrong compilation/ .obj file?</p>
  
  <p>This was working well yesterday</p>
  
  <p>Some advice?</p>
  
  <p><strong>Edit:</strong> The declaration of  m_imageMap is very simple:</p>
  
  <pre><code>typedef std::map&lt;unsigned int,utils::CImageBuff&gt; t_imageMap;
  </code></pre>
  
  <p>As additional information, the exception generated is into the line 1643 of the file output.c.</p>
  
  <p><strong>Edit</strong> Well, I'm very dissapointed with this case. I've changed the code so now the class no longer is a singleton. Now only m_imageMap is static to make all loaded images visible from any place. But still fails in the same way. The error is an <strong>access violation</strong>. Moreover, if I change all the method code by this code by this:</p>
  
  <pre><code>utils::CImageBuff im;
  m_imageMap[1] = im;    // fails here
  return &amp;im; 
  </code></pre>
  
  <p>still fails. It is like the map is null or locked in any way, or even bad initialized, but I don't know. Could you helpme?</p>
  
  <p>If you need some more code, I'll paste, but crashing with this three lines simplifies the problem, I think.</p>
  
  <p><strong>Edit: Finally solved</strong> Finally I've changed from  </p>
  
  <pre><code>std::map&lt;unsigned int,utils::CImageBuff&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>std::map&lt;unsigned int,utils::CImageBuff*&gt;
  </code></pre>
  
  <p>And now it works. Now I simply need to think a method to delete the contents of an static std::map of pointers.</p>
  
  <p>Many thanks to all</p>