------- Comment #5 from bkoz at gcc dot gnu dot org 2009-02-03 23:47 ------- > Benjamin, does you have an opinion about initializer-lists and complex? I > guess the library complex class will accept { real, imag } naturally because > it > has a suitable constructor.
It would be great if this stuff matched for C/C++. #include <complex> std::complex<double> z1{1.1, 2.2}; std::complex<double> z2{3.3}; std::complex<double> z3{ }; all work with -std=gnu++0x, but not with -std=c++98. So, direct list init works for C++ std::complex. All forms of copy-list init fail for std::complex though. std::complex<double> z4 = {1.1, 2.2}; std::complex<double> z5 = {3.3}; std::complex<double> z6 = { }; complex_init.cc:9: error: call of overloaded complex(<brace-enclosed initializer list>) is ambiguous /mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/complex:1174: note: candidates are: std::complex<double>::complex(const std::complex<float>&) /mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/complex:1162: note: std::complex<double>::complex(const std::complex<double>&) There seems to be some inconsistency in the way this is defined, will bring up on libstdc++-ml/LWG. The original testcase: __complex__ int i({0}); fails in the C++ version: std::complex<double> i({0}); So that part is consistent. -benjamin -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056