title: Metafunction to convert a type to an integer and vice-versa
body: <p>The <code>typeid</code> allows to assign a unique <code>std::type_index</code> to each type at runtime. I would like to do the same, statically using two metafunctions :</p>
  
  <pre><code>// Get a unique integral number associated with the provided type
  template &lt;class T&gt;
  struct encode_type
  {
      using type = T;
      static constexpr std::size_t value = /* Metaprogramming magic */;
  };
  
  // Get the type uniquely associated with the provided value
  template &lt;std::size_t V&gt;
  struct decode_type
  {
      static constexpr std::size_t value = V;
      using type = /* Metaprogramming magic */;
  };
  </code></pre>
  
  <p>Is there a way to do that in C++11?</p>