How to deduce template type if I only got pointer to base class
<p>How could I implement function <code>Foo</code> to dispatch to the correct function?</p>

<p>The following code reproduces the problem, and got some additional information in comments.</p>

<pre><code>#include &lt;string&gt;

class Base  
{
public:
virtual ~Base(){};
};

template&lt;typename T&gt;
class Derived : public Base 
{};

void DoSomething(const Derived&lt;std::string&gt; &amp;){};
void DoSomething(const Derived&lt;int&gt; &amp;){};

void Foo(Base *test)
{
    // How to call correct DoSomething method?
    // (I can't change class Base, but I know that test points to some instance of class Derived)?
    // if(test points to an instance of Derived&lt;int&gt;)
    //     call void DoSomething(const Derived&lt;int&gt; &amp;){};
    // else if(test points to an instance of Derived&lt;std::string&gt;)
    //     call void DoSomething(const Derived&lt;std::string&gt; &amp;){};
}

int main(int argc, char* argv[])
{
    Base *test = new Derived&lt;int&gt;;

    Foo(test);

    delete test;
    return 0;
}
</code></pre>
