<p>The following code:</p>

<pre><code>template &lt;typename S, typename T&gt;
struct foo {
   void bar();
};

template &lt;typename T&gt;
void foo &lt;int, T&gt;::bar() {
}
</code></pre>

<p>gives me the error</p>

<pre><code>invalid use of incomplete type 'struct foo&lt;int, T&gt;'
declaration of 'struct foo&lt;int, T&gt;'
</code></pre>

<p>(I'm using gcc.) Is my syntax for partial specialization wrong? Note that if I remove the second argument:</p>

<pre><code>template &lt;typename S&gt;
struct foo {
   void bar();
};

template &lt;&gt;
void foo &lt;int&gt;::bar() {
}
</code></pre>

<p>then it compiles correctly.</p>

You can't partially specialize a function. If you wish to do so on a member function, you must partially specialize the entire template (yes, it's irritating). On a large templated class, to partially specialize a function, you would need a workaround. Perhaps a templated member struct (e.g.
```
template <typename U = T> struct Nested
```
) would work. Or else you can try deriving from another template that partially specializes (works if you use the
```
this->member
```
notation, otherwise you will encounter compiler errors).