title: Variadic template type unpacking into map keys
body: <p>I'm trying to create a class which will contain a map of <code>type_index</code> keys mapped to pointers of each type passed as a template argument. This would allow me to specify a series of types my class will rely on in it's declaration.</p>
  
  <p>I've done a bit of research but can only seem to find ways to unpack arguments, rather than types. I'm new to this subject, and would appreciate any clarification on terminology, or references to relevant text.</p>
  
  <pre><code>template &lt;typename T&gt;
  T* SomeFakeFactoryGetter() { return new T(); }
  
  template &lt;class... Injected&gt;
  class UtilityProvider
  {
  public:
      template &lt;class U&gt;
      U* GetUtility()
      {
          std::type_index idx = std::type_index(typeid(U));
          assert(_injectedClasses.find(idx) != _injectedClasses.end());
          return reinterpret_cast&lt;U*&gt;(_injectedClasses[idx]);
      }
  
      // **
      // How would I *unpack* all types for use as indices into my map?
      // ( I realise this function is not what I want.)
      template &lt;Injected... C&gt;
      void Unpack()
      {
          _injectedClasses[std::type_index(typeid(C))] = SomeFakeFactoryGetter&lt;C&gt;();
      }
  
  private:
      typedef std::unordered_map&lt;std::type_index, void*&gt; InjectedMap;
      InjectedMap _injectedClasses;
  };
  
  class Bar{ public: void A() { printf("Hello bar"); } };
  class Baz{ public: void B() { printf("Hello baz"); } };
  class Nope {};
  
  class Foo : public UtilityProvider&lt;Bar, Baz&gt;
  {
  public:
      Foo()
      {
          GetUtility&lt;Bar&gt;()-&gt;A();
          GetUtility&lt;Nope&gt;(); // Fail. User must specify which utilities this class     will use.
      }
  };
  </code></pre>