Boost logo

Boost :

From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2021-02-08 18:47:11


> It would be very desirable to implement all> conversion ctors generically so that both> directions work...
The plan is to try to achieve generally the following:

*Interface model based on C++14 <complex>.

* Use C99 Annex G to guide us for the rightspecial values to return for arguments zero,INF, NaN?

Are those two top-level requirements OK,or at least a good start, more right (less wrong)?
Kind regards, Chris
    On Monday, February 8, 2021, 7:40:12 PM GMT+1, Gero Peterhoff via Boost <boost_at_[hidden]> wrote:
 
 It would be very desirable to implement all conversion ctors generically so that both directions work:
1)
std::complex<double> a{1.1, 2.2};
std::complex<int> b{a}; // works
2)
std::complex<int> a{1, 2};
std::complex<double> b{a}; // doesn't work
without explicit call
std::complex<double> b{a.real(), a.imag()};
or
std::complex<double> b{double(a.real()), double(a.imag())};
to prevent warnings.

This is cumbersome, confusing and a source of errors.

Am 08.02.21 um 19:04 schrieb John Maddock via Boost:
> On 08/02/2021 17:30, Gero Peterhoff via Boost wrote:
>> That's the problem: the generic std::complex class has generic conversion ctors, the FP specializations don't. I don't understand why this is done.
>
> Actually the generic template specification is redundant given that only float/double/long double specializations are allowed.
>
> BTW the specializations do have converting constructors, but they are explicit when narrowing which is the right design IMO.
>
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
  


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk