class SomeObject {};<BR><BR>class Demonstration<BR>{<BR> template <class T> void foo(const T& value) { }<BR> template <> void foo(const SomeObject*& value) { }<BR>};There are two issues with this code, one is what causes the error, the other isn't caught by VC.
The issue that causes this code to fail to compile is this: template <> void foo(const SomeObject*& value); has a signature that doesn't correspond to the template, so it isn't a valid specialization. The template wants a const reference, and you'd think that your specialization has a signature specifying "const reference to a pointer", but due to the (sometimes insane) order in which declarations are read in C++, the actual signature is "reference to a const pointer" which doesn't match the template.
There is a second issue here: specializations are not allowed inside class definitions. VC does allow them there, but Comeau does not. So just fixing the definition makes the code work on VC, but still not entirely up to spec with the ISO standard. This bit may also have something to do with why VC2005 still gives an ICE with the declarations-only version.
So the following code is a completely correct version, which compiles fine in VC2003, VC2005, and Comeau 4.3.3:
class SomeObject {};<BR><BR>class Demonstration<BR>{<BR> template <class T> void foo(const T& value) { }<BR>};<BR><BR>template <> void foo(SomeObject* const & value) { }There is still the matter of the ICE. You never want a compiler to give an ICE on any input, ideally. VC (both 2003 and 2005) give an Internal Compiler Error when these two conditions are both met: 1. the function specialization is inside the class definition and 2. the specialisation has no method body. The ICE still occurs if the method body is defined elsewhere.
I will file an issue against VC2005 on this matter.