Rafal Dabrowa wrote in news:co5fi9$847$1@news.onet.pl in comp.lang.c++:
[color=blue]
> Consider the following code:
> template <class T>
> void f(T, int) {}
> template <class T>
> void f(int, T) {}
> template<>
> void f(int, int) {} // ambiguous ?
>
> My compiler complains that the last definition is an "ambiguous
> template
> specialization `f<>' for `void f(int, int)' ". I have tested this on a
> few compilers and all they complain there. What is wrong in this
> specialization ? Consider similar code:
> template <class T, class C>
> void f(int, T, C) {}
> template <class T, class C>
> void f(T, int, C) {}
> template<class C>
> void f(int, int, C) {}
>
> Compiler does not complain that 3rd function is ambiguous. Why ? What
> is the difference ?
>[/color]
The diffrence is that in the second example you aren't
specializing anything, you are just providing an overload
that happens to be a template.
In the first example the explicit specialization f<>(int, int)
could be a specialization of either of the two overloads that
preceded it, hence the ambiguity.
HTH.
[color=blue]
> --
> sed -e s/s/a/g <my_address >my_right_address
>[/color]
Rob.
--
http://www.victim-prime.dsl.pipex.com/