<div class="gmail_quote">2009/2/19 Neal Becker <span dir="ltr"><<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>></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<typename in_t><br> void F (in_t & in) ...<br> <br> main() {<br> F<std::vector<int> > (...)<br> <br> Suppose in_t is a templated container, such as std::vector<int>. Is there a<br> way within the function 'F' to get the generic container type, 'std::vector'<br> when F is instantiated with a specific e.g., std::vector<int>?<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 <class Base, class Arg> struct rebind; template <template <class> class Base, class T, class Arg> struct rebind<Base<T>, Arg> { typedef Base<Arg> type; }; template <class In> void foo() { // d is of type container<double>. typename rebind<In, double>::type d; } template <class T> struct container {}; int main() { foo<container<int> >(); } </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'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>