wrote:
> Yeah my code is kinda long so i chose not to post it.
My crystal ball is in the repair shop, so I chose not to guess.
> I just dont
> understand why it works for almost all conversions (from
> int,float,double,complex float, complex double to
> int,float,double,complex float, complex double) except for float to
> double, in which case it calls my specialized template function
> (Complex float to float) and complains that norm(double) has no
> matching function. It seems to me double gets promoted to complex float
> implicitly or something.
>
There is no implicit promotion from double to _anything_. The only
standard floating point promotion is float -> double. There are floating
point _conversions_, which allow an rvalue of one FP type to be converted
to an rvalue of another FP type. std::complex<something> is essentially
a user-defined type, so any conversion from 'something' to it would *not*
be a standard conversion or a promotion, but a user-defined conversion.
AFAICS, std::complex<T> is defined with a converting constructor with two
arguments both of which have a default argument value, T(). RTFM. That
constructor can be used to convert 'float' to 'std::complex<float>' or
even 'double' to 'std::complex<float>'. IOW, you may write
std::complex<float> cf(1.0);
which defines 'cf' and initialises it with real == 1.f, imaginary == 0.f.
How it reflects on the functionality of your special code, I've no idea.
V