Hi,
I try to do a bit of templating, but there is a problem.

/// base template. no implementation, just declaration.
template<typename ANY> void func(ANY&);

/// specialization for int
template<> void func<int>(int &val) { val = 7; }

/// specialization for string
template<> void func<string>(string&val) { val="hello"; }


but: when I write somewhere in my code

main(...)
{
string s1;
func(s1); // fine

const string s2;
func(s2); // compiles, but link error.
}


What happens is clear: I only specialized the non-const-ref version for "string", but I would need the const-ref here. So the compiler falls back on the unspecialized variant here, where I did not provide an implementation for. This of course the compiler can not detect, because I could provide an implementation anywhere, if I liked. But the linker will fail, because I dont provide one -- because the way I use "func()" a const-ref would not make sense.


I wonder, is there some mechanism which I could use to let the compiler warn me when I use "func" on a "const string"?

Thanks in advance.

tschau, towi.