AMDG Joel FALCOU wrote:
Isn't that what the std::complex default constructor does?
It does and I think it's a bad practice.
Why?
explicit complex(const complex<double>&); explicit complex(const complex<long double>&);
Why are they explicit ? Where is the risk to have non-explicit destructor ?
they are implicit for float -> double or long double and double to long double. In other words, the constructors are explicit when an implicit conversion would normally generate a warning for the value type.
Is having the followign triplet lead to ambiguity ?
template
complex<T> operator+(const U& lhs, const complex<T>& rhs); template complex<T> operator+(const complex<T>& lhs, const U& rhs); template complex<T> operator+(const complex<U>& lhs, const complex<T>& rhs);
Yes. We ran into this with the Units library. If two different class templates define such overloads, then trying to add them is ambiguous.
If it did, shouldn't SFINAE make the cut by restrictng U to types that verify : boost::is_floating_points<U>::value == true ?
Ok. In Christ, Steven Watanabe