Below are lines from "the c++ programming language"
template<class T > T sqrt(T );
template<class T > complex<T> sqrt(complex<T>);
double sqrt(double);
void f(complex<double> z )
{
s q r t (2 ); // sqrt<int>(int)
sqrt(2.0) ; // sqrt(double)
sqrt(z) ; // sqrt<double>(complex<double>)
}
I dont understand why sqrt(z) ; calls sqrt<double>(complex<double>)
can any body please explain.
Author says,
T sqrt<complex<T>>
is more specialized than T sqrt <T>
but there is a seperate declaration for template<class T > complex<T> sqrt(complex<T>);
why not use that?