Define and deduce the parameter from Template template parameter
<p>Based on the example on <a href="http://rads.stackoverflow.com/amzn/click/059600298X" rel="nofollow">pp. 179</a></p>

<pre><code>template&lt;template&lt;typename T, typename A&gt; class C, typename T, typename A&gt;
                                                   ^^^^^^^^^^^^^^^^^^^^^^
void erase(C&lt;T, A&gt;&amp;c, const T&amp; item)
{
    c.erase(std::remove(c.begin(), c.end(), item), c.end());
}

int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
{
    list&lt;int&gt; lst;
    lst.push_back(42);
    erase(lst, 42);
}
</code></pre>

<p>If I remove the <code>typename T, typename A</code> from the <code>erase</code> function signature, the VS2010 compiler gives the following errors:</p>

<blockquote>
<pre><code>Error 1   error C2065: 'T' : undeclared identifier
Error 2   error C2065: 'A' : undeclared identifier
Error 3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 4   error C2143: syntax error : missing ',' before '&amp;'
</code></pre>
</blockquote>

<p><strong>Question1</strong>> What is the reason behind these compilation errors. </p>

<p>Is it true that we always have to explicitly define the type parameters used in the template template parameter?</p>

<p><strong>Question2</strong>> When we call the following line, how does compiler deduce the type of <code>A</code>?</p>

<pre><code>erase(lst, 42)
</code></pre>

<p>Is it true that the compiler deduce the type <code>A</code> based on the default argument for template parameter A that is defined in <code>list</code>?</p>

<p>Refer to <a href="http://www.cplusplus.com/reference/stl/list/" rel="nofollow">list</a>   </p>

<pre><code>template &lt; class T, class Allocator = allocator&lt;T&gt; &gt; class list;
</code></pre>

<p>And the type <code>A</code> is <code>allocator&lt;T&gt;</code>?</p>
