Specialization template class with templated function
<p>I have some helper template with templated function. I'm using it for other policy-based templated class to cast or not to cast some value to specific type:</p>

<pre><code>// use this when needed additional value cast
template &lt;typename T&gt;
struct AdditionalValueStaticCaster
{
    template &lt;typename U&gt;
    static T cast(U u)
    {
        return static_cast&lt;T&gt;(u);
    }
};

// use this specialization when no needed to cast value
template &lt;&gt;
struct AdditionalValueStaticCaster&lt;void&gt;
{
    template &lt;typename U&gt;
    static U cast(U u)
    {
        return u;
    }
};
</code></pre>

<p>Now I want to split these classes to declaration and implementation (.h and .hh files)</p>

<p>So I write declaration like this:</p>

<pre><code>template &lt;typename T&gt;
struct AdditionalValueStaticCaster
{
    template &lt;typename U&gt;
    static T cast(U u);
};


template &lt;&gt;
struct AdditionalValueStaticCaster&lt;void&gt;
{
    template &lt;typename U&gt;
    static U cast(U u);
};
</code></pre>

<p>And now I want to write implementation. This is ok:</p>

<pre><code>template &lt;typename T&gt;
template &lt;typename U&gt;
T AdditionalValueStaticCaster&lt;T&gt;::cast(U u)
{
    return static_cast&lt;T&gt;(u);
}
</code></pre>

<p>But this causes error <code>error: too many template-parameter-lists</code></p>

<pre><code>template&lt;&gt;
template &lt;typename U&gt;
U AdditionalValueStaticCaster&lt;void&gt;::cast(U u)
{
    return u;
}
</code></pre>

<p>If I delete line <code>template&lt;&gt;</code> all compiles ok, but I still have a question: is it right solution or I missed something?</p>