The code below will not compile with g ++ version 4.5.0 using the -std=c++0x switch. The following error message appears:
error: no match for 'operator+' in 'std::pow [with _Tp = float, _Up = int, typename __gnu_cxx::__promote_2<_Tp, _Up>::__type = double](((const std::complex<float>&)((const std::complex<float>*)(& x))), ((const int&)((const int*)(&2)))) + y'
I believe this is due to the assignment requirement mentioned here . Should I define my own copy assignment operator for complex? If so, how?
#include <complex> using namespace std; int main(int argc, char *argv[]) { complex<float> x,y; x = pow(x,2); // ok x = x + y; // ok x = pow(x,2) + y; // error return 0; }
source share