title: Exception thrown: read access violation. _Scary was nullptr
body: <p>Trying to learn to code using Jim Horton's Beginning C++ Programming with Jim Horton. It's crashing with the following:</p>
  
  <pre><code>ZombieArena.exe!std::_Tree&lt;std::_Tmap_traits&lt;std::string,sf::Texture,std::less&lt;std::string&gt;,std::allocator&lt;std::pair&lt;std::string const ,sf::Texture&gt;&gt;,0&gt;&gt;::_Find_lower_bound&lt;std::string&gt;(const std::string &amp; _Keyval) Line 1704    C++
  ZombieArena.exe!std::_Tree&lt;std::_Tmap_traits&lt;std::string,sf::Texture,std::less&lt;std::string&gt;,std::allocator&lt;std::pair&lt;std::string const ,sf::Texture&gt;&gt;,0&gt;&gt;::_Find&lt;std::string&gt;(const std::string &amp; _Keyval) Line 1457    C++
  ZombieArena.exe!std::_Tree&lt;std::_Tmap_traits&lt;std::string,sf::Texture,std::less&lt;std::string&gt;,std::allocator&lt;std::pair&lt;std::string const ,sf::Texture&gt;&gt;,0&gt;&gt;::find(const std::string &amp; _Keyval) Line 1466  C++
  ZombieArena.exe!TextureHolder::GetTexture(const std::string &amp; filename) Line 21 C++
  ZombieArena.exe!Zombie::spawn(float startX, float startY, int type, int seed) Line 28   C++
  </code></pre>
  
  <p>The code for this is:</p>
  
  <pre><code>    #pragma once
  
  #ifndef TEXTURE_HOLDER_H
  #define TEXTURE_HOLDER_H
  #include &lt;SFML/Graphics.hpp&gt;
  #include &lt;map&gt;
  
  using namespace sf;
  using namespace std;
  
  class TextureHolder
  {
  private:
      // A map container from the STL,
      // that holds related pairs of String and Texture
      map&lt; string, Texture&gt; m_Textures;
      // A pointer of the same type as the class itself
      // the one and only instance
      static TextureHolder* m_s_Instance;
  public:
      TextureHolder();
      static Texture&amp; GetTexture(string const&amp; filename);
  };
  #endif
  </code></pre>
  
  <p>The cpp file is:</p>
  
  <pre><code>    #include "TextureHolder.h"
  
  // Include the "assert feature"
  #include &lt;assert.h&gt;
  
  TextureHolder* TextureHolder::m_s_Instance = nullptr;
  TextureHolder::TextureHolder()
  {
      assert(m_s_Instance == nullptr);
      m_s_Instance = this;
  }
  
  Texture&amp; TextureHolder::GetTexture(string const&amp; filename)
  {
      // Get a reference to m_Textures using m_s_Instance
      auto&amp; m = m_s_Instance-&gt;m_Textures;
      // auto is the equivalent of map&lt;string, Texture&gt;
      // Create an iterator to hold a key-value-pair (kvp)
      // and search for the required kvp
      // using the passed in file name
      auto keyValuePair = m.find(filename);
      // auto is equivalent of map&lt;string, Texture&gt;::iterator
      // Did we find a match?
      if (keyValuePair != m.end())
      {
          // Yes
          // Return the texture,
          // the second part of the kvp, the texture
          return keyValuePair-&gt;second;
      }
      else
      {
          // File name not found
          // Create a new key value pair using the filename
          auto&amp; texture = m[filename];
          // Load the texture from file in the usual way
          texture.loadFromFile(filename);
          // Return the texture to the calling code
          return texture;
      }
  }
  </code></pre>
  
  <p>It crashes on the 2nd auto line for the map find. Any ideas???? I'm confused. Thanks in advance.</p>