|
Boost Users : |
From: Joel FALCOU (joel.falcou_at_[hidden])
Date: 2008-06-02 12:34:03
> Isn't that what the std::complex default constructor does?
It does and I think it's a bad practice.
> explicit complex(const complex<double>&);
> explicit complex(const complex<long double>&);
Why are they explicit ? Where is the risk to have non-explicit destructor ?
> The standard states that "The effect of instantiating the template
> complex for any type other than
> float, double or long double is unspecified." (26.2)
A point I wasn't aware of. What about enforcing this at the compile-time
level using CT-assert ?
> I think that you are correct about operators on two complex types.
> However, it is probably not a good idea to have operator overloads like the following
> template<class T, class U> complex<T> operator+(const U& lhs, const
> complex<T>& rhs); because they can cause ambiguities.
Is having the followign triplet lead to ambiguity ?
template<class T, class U>
complex<T> operator+(const U& lhs, const complex<T>& rhs);
template<class T, class U>
complex<T> operator+(const complex<T>& lhs, const U& rhs);
template<class T, class U>
complex<T> operator+(const complex<U>& lhs, const complex<T>& rhs);
If it did, shouldn't SFINAE make the cut by restrictng U to types that
verify : boost::is_floating_points<U>::value == true ?
For me, it looks like complex can be reworked with current technologies
to enforce its behavior and adds the missing pieces.
-- Joel FALCOU Research Engineer @ Institut d'Electronique Fondamentale Université PARIS SUD XI France
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net