one thing that bugs me about c++
Sean Kelly
sean at f4.ca
Thu Dec 13 17:16:31 PST 2007
Neal Becker wrote:
> In c++,
>
> template<typename T>
> void F (T);
>
> template<typename T>
> void F (std::complex<T>);
>
> This doesn't work. I want the second overload to be the 'best' match for
>
> F (std::complex<double>)
>
> for example, but the standard doesn't agree.
>
> Never really made sense to me. What would D do?
Seems I need to brush up on my knowledge of template overload
resolution, as I'd expect the second overload to be chosen for the
reason you provide. Still, perhaps it isn't truly "more specialized"
because in each case a T is being substituted into the one parameter?
I'll give the C++ spec a gander on my way home and see if I can come up
with anything more enlightening.
Sean
More information about the Digitalmars-d
mailing list