title: Why use std::type_index instead of std::type_info*
body: <p>I need to key some data in a map by a type. Currently I have something like this:</p>
  
  <pre><code>struct TypeInfoComparer
  {
    bool operator()(std::type_info const* a, std::type_info const* b) const
    {
      return a-&gt;before(*b);
    };
  };
  
  std::map&lt;std::type_info const*, Foo, TypeInfoComparer&gt; d_fooByTypeId;
  </code></pre>
  
  <p>Which I can then look up from using (for example, in a template method having <code>&lt;typename T&gt;</code>:</p>
  
  <pre><code>auto pair = d_fooByTypeId.find(&amp;typeid(T));
  </code></pre>
  
  <p>However today I was reading about <a href="http://en.cppreference.com/w/cpp/types/type_index"><code>std::type_index</code></a> which seems to be intended for use in such a case as this.</p>
  
  <p>I'm interested in improving my C++ knowledge. Can someone please explain whether I should modify my code to use <code>std::type_index</code>, and why? Is there a reason beyond being able to remove the <code>TypeInfoComparer</code>?</p>