Consider the following code:
std::complex<double> a = -1.0i * 42.0; std::complex<double> b = a + 1.0i;
The second line fails to compile with:
error: no match for ‘operator+’ (operand types are ‘std::complex<double>’ and ‘__complex__ double’)
This also shows up when using the complex literal in function calls, e.g.
std::exp<std::complex<double>>( 1.0i * 3.14159 );
How come the complex literal
1.0i is not convertible to
Do I have to explicitly construct a
You should recompile with
--std=c++14 (no GNU ext) to avoid conflict of
i suffix with gcc extension
The ISO C++14 library also defines the ‘i’ suffix, so C++14 code that includes the
<complex>header cannot use ‘i’ for the GNU extension. The ‘j’ suffix still has the GNU meaning.