Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-06-02 12:43:02


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<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);
>

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


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