title: How to fix "<hash_map> is deprecated and will be REMOVED. Please use <unordered_map>"?
body: <p>I am learning C++ so I am working through the book <em>Programming: Principles and Practice using C++</em>.</p>
  
  <p>I am on the first drill, which is how to make a 'Hello, World!' program using Microsoft Visual Studio 2015. I have used the source code as provided in the book.</p>
  
  <pre><code>#include "../../std_lib_facilities.h"  //header file recommended by book
  int main()                             //C++ programs start by executing the function main
  {
      cout &lt;&lt;"Hello, World!\n";   //output "Hello, World!"
      keep_window_open();         //wait for a character to be entered
      return 0;
  }
  </code></pre>
  
  <p>However, I receive two errors when I try to build an executable program which are as follows:</p>
  
  <pre><code>IntelliSense: static assertion failed with "&lt;hash_map&gt; is    
  deprecated and will be REMOVED. Please use &lt;unordered_map&gt;. You can define
  _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to acknowledge that you have 
  received this warning." 
  Project: Hello, World!  
  c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\hash_map 
  Line 14
  
  Error   C2338   &lt;hash_map&gt; is deprecated and will be REMOVED. Please use 
  &lt;unordered_map&gt;. You can define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to 
  acknowledge that you have received this warning.    
  Project: Hello, World!  
  c:\program files (x86)\microsoft visual studio 14.0\vc\include\hash_map 
  Line 17
  </code></pre>
  
  <p>Could you explain to me how I can rectify this?</p>
  
  <p>The code in the std_lib_facilities.h is as follows:</p>
  
  <pre><code>/*
      simple "Programming: Principles and Practice using C++" course header to
      be used for the first few weeks.
      It provides the most common standard headers (in the global namespace)
      and minimal exception/error support.
  
      Students: please don't try to understand the details of headers just yet.
      All will be explained. This header is primarily used so that you don't     have
      to understand every concept all at once.
  
      Revised April 25, 2010: simple_error() added
  */
  
  #ifndef H112
  #define H112 201004L
  
  #include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;sstream&gt;
  #include&lt;cmath&gt;
  #include&lt;cstdlib&gt;
  #include&lt;string&gt;
  #include&lt;list&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  #include&lt;stdexcept&gt;
  
  //---------------------------------------------------------------------------    ---
  
  #ifdef _MSC_VER
  #include &lt;hash_map&gt;
  using stdext::hash_map;
  #else
  #include &lt;ext/hash_map&gt;
  using __gnu_cxx::hash_map;
  
  namespace __gnu_cxx {
  
      template&lt;&gt; struct hash&lt;std::string&gt;
      {
          size_t operator()(const std::string&amp; s) const
          {
              return hash&lt;char*&gt;()(s.c_str());
          }
      };
  
  } // of namespace __gnu_cxx
  #endif
  
  //---------------------------------------------------------------------------    ---
  
  #define unordered_map hash_map
  
  //---------------------------------------------------------------------------    ---
  
  typedef long Unicode;
  
  //---------------------------------------------------------------------------    ---
  
  using namespace std;
  
   template&lt;class T&gt; string to_string(const T&amp; t)
  {
      ostringstream os;
      os &lt;&lt; t;
      return os.str();
  }
  
  struct Range_error : out_of_range { // enhanced vector range error reporting
      int index;
      Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i)     { }
  };
  
  
  // trivially range-checked vector (no iterator checking):
  template&lt; class T&gt; struct Vector : public std::vector&lt;T&gt; {
      typedef typename std::vector&lt;T&gt;::size_type size_type;
  
      Vector() { }
      explicit Vector(size_type n) :std::vector&lt;T&gt;(n) {}
      Vector(size_type n, const T&amp; v) :std::vector&lt;T&gt;(n,v) {}
      template &lt;class I&gt;
      Vector(I first, I last) :std::vector&lt;T&gt;(first,last) {}
  
      T&amp; operator[](unsigned int i) // rather than return at(i);
      {
          if (i&lt;0||this-&gt;size()&lt;=i) throw Range_error(i);
          return std::vector&lt;T&gt;::operator[](i);
      }
      const T&amp; operator[](unsigned int i) const
      {
          if (i&lt;0||this-&gt;size()&lt;=i) throw Range_error(i);
          return std::vector&lt;T&gt;::operator[](i);
      }
  };
  
  // disgusting macro hack to get a range checked vector:
  #define vector Vector
  
  // trivially range-checked string (no iterator checking):
  struct String : std::string {
  
      String() { }
      String(const char* p) :std::string(p) {}
      String(const string&amp; s) :std::string(s) {}
      template&lt;class S&gt; String(S s) :std::string(s) {}
      String(int sz, char val) :std::string(sz,val) {}
      template&lt;class Iter&gt; String(Iter p1, Iter p2) : std::string(p1,p2) { }
  
      char&amp; operator[](unsigned int i) // rather than return at(i);
      {
          if (i&lt;0||size()&lt;=i) throw Range_error(i);
          return std::string::operator[](i);
      }
  
      const char&amp; operator[](unsigned int i) const
      {
          if (i&lt;0||size()&lt;=i) throw Range_error(i);
          return std::string::operator[](i);
      }
  };
  
  #ifndef _MSC_VER
  namespace __gnu_cxx {
  
      template&lt;&gt; struct hash&lt;String&gt;
      {
          size_t operator()(const String&amp; s) const
          {
              return hash&lt;std::string&gt;()(s);
          }
      };
  
  } // of namespace __gnu_cxx
  #endif
  
  
  struct Exit : runtime_error {
      Exit(): runtime_error("Exit") {}
  };
  
  // error() simply disguises throws:
  inline void error(const string&amp; s)
  {
      throw runtime_error(s);
  }
  
  inline void error(const string&amp; s, const string&amp; s2)
  {
      error(s+s2);
  }
  
  inline void error(const string&amp; s, int i)
  {
       ostringstream os;
      os &lt;&lt; s &lt;&lt;": " &lt;&lt; i;
      error(os.str());
  }
  
  #if _MSC_VER&lt;1500
      // disgusting macro hack to get a range checked string:
      #define string String
      // MS C++ 9.0 have a built-in assert for string range check
      // and uses "std::string" in several places so that macro substitution      fails
  #endif
  
  template&lt;class T&gt; char* as_bytes(T&amp; i)  // needed for binary I/O
  {
      void* addr = &amp;i;    // get the address of the first byte
                          // of memory used to store the object
      return static_cast&lt;char*&gt;(addr); // treat that memory as bytes
  }
  
  
  inline void keep_window_open()
  {
      cin.clear();
      cout &lt;&lt; "Please enter a character to exit\n";
      char ch;
      cin &gt;&gt; ch;
      return;
  }
  
  inline void keep_window_open(string s)
  {
      if (s=="") return;
      cin.clear();
      cin.ignore(120,'\n');
      for (;;) {
          cout &lt;&lt; "Please enter " &lt;&lt; s &lt;&lt; " to exit\n";
          string ss;
          while (cin &gt;&gt; ss &amp;&amp; ss!=s)
              cout &lt;&lt; "Please enter " &lt;&lt; s &lt;&lt; " to exit\n";
          return;
      }
  }
  
  
  
  // error function to be used (only) until error() is introduced in Chapter 5:
  inline void simple_error(string s)  // write ``error: s?? and exit program
  {
      cerr &lt;&lt; "error: " &lt;&lt; s &lt;&lt; '\n';
      keep_window_open();     // for some Windows environments
      exit(1);
  }
  
  // make std::min() and std::max() accessible:
  #undef min
  #undef max
  
  #include&lt;iomanip&gt;
  inline ios_base&amp; general(ios_base&amp; b)   // to augment fixed and scientific
  {
      b.setf(ios_base::fmtflags(0),ios_base::floatfield);
      return b;
  }
  
  // run-time checked narrowing cast (type conversion):
  template&lt;class R, class A&gt; R narrow_cast(const A&amp; a)
  {
      R r = R(a);
      if (A(r)!=a) error(string("info loss"));
      return r;
  }
  
  
  inline int randint(int max) { return rand()%max; }
  
  inline int randint(int min, int max) { return randint(max-min)+min; }
  
  inline double sqrt(int x) { return sqrt(double(x)); }   // to match C++0x
  
  #endif
  </code></pre>