------- Comment #37 from jason at gcc dot gnu dot org 2008-01-22 15:37 ------- (In reply to comment #7) > Since complex types are arithmetic types in GNU C++, we should allow standard > conversions to them from integers, just as we do for all other arithmetic > types. > > However, this runs into problems with libstdc++. In particular, > std::complex<double> has a constructor from double and also a constructor from > __complex__ double. Making the change in this patch makes that conversion > ambiguous because now "std::complex<double>(1)" can go via either the > "__complex__ double" constructor or the plain "double" constructor.
It seems clear to me that conversion to complex should be worse than conversion to another scalar arithmetic type. I would implement this in hypothetical standardese by defining "complex conversions" for the conversion from scalar to complex, and the term "scalar arithmetic conversions" for integer, float and integer-float conversions, then adding to 13.3.3.2p3 an additional rule that S1 is better than S2 if S1 is a scalar arithmetic conversion and S2 is a complex conversion. I think this approach would avoid the need for extra constructors. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31780