<div class="gmail_quote">2009/2/19 Neal Becker <span dir="ltr">&lt;<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Say I have:<br>
<br>
template&lt;typename in_t&gt;<br>
void F (in_t &amp; in) ...<br>
<br>
main() {<br>
 &nbsp;F&lt;std::vector&lt;int&gt; &gt; (...)<br>
<br>
Suppose in_t is a templated container, such as std::vector&lt;int&gt;. &nbsp; Is there a<br>
way within the function &#39;F&#39; to get the generic container type, &#39;std::vector&#39;<br>
when F is instantiated with a specific e.g., std::vector&lt;int&gt;?<br></blockquote></div><br><div>Maybe this will help you.</div><div><br></div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">template &lt;class Base, class Arg&gt;
struct rebind;

template &lt;template &lt;class&gt; class Base,
          class T,
          class Arg&gt;
struct rebind&lt;Base&lt;T&gt;, Arg&gt; {
  typedef Base&lt;Arg&gt; type;
};

template &lt;class In&gt;
void foo() {
  // d is of type container&lt;double&gt;.
  typename rebind&lt;In, double&gt;::type d;
}

template &lt;class T&gt;
struct container {};

int main() {
  foo&lt;container&lt;int&gt; &gt;();
}
</span></div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br></span></div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">With vector and other STL containers it&#39;s a bit</span></div>
<div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">harder, because they can have more than one</span></div>
<div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">template parameter.</span></div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Roman Perepelitsa.</span></div>