one thing that bugs me about c++

Walter Bright newshound1 at digitalmars.com
Thu Dec 13 17:13:22 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?

void F(T)(T t) { ... }
void F(T:cdouble)(T t) { ... }

should do it.



More information about the Digitalmars-d mailing list