title: Retrieve the template a type is instantiated from
body: <p>How can I retrieve the template a type was originally instantiated from?</p>
  
  <p>I'd like to do the following:</p>
  
  <pre><code>struct Baz{};
  struct Bar{};
  
  template &lt;typename T&gt;
  struct Foo {};
  
  using SomeType = Foo&lt;Bar&gt;;
  
  template &lt;typename T&gt;
  using Template = get_template&lt;SomeType&gt;::template type&lt;T&gt;;
  
  static_assert(std::is_same&lt;Foo&lt;Baz&gt;, Template&lt;Baz&gt;&gt;::value, "");
  </code></pre>
  
  <p>I know I can achieve this through partial specialization, but this forces me to specialize <code>get_template</code> for every template I want to use it with:</p>
  
  <pre><code>template &lt;typename T&gt;
  struct get_template;
  
  template &lt;typename T&gt;
  struct get_template&lt;Foo&lt;T&gt;&gt;
  {
      template &lt;typename X&gt;
      using type = Foo&lt;X&gt;;
  };
  </code></pre>
  
  <p><kbd><a href="http://coliru.stacked-crooked.com/a/f4f9bb31daab3619" rel="nofollow">live example</a></kbd></p>
  
  <p>Is there a way around this limitation?</p>