help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ... where cfront would use ...


From: Guy Harrison
Subject: Re: ... where cfront would use ...
Date: Tue, 13 Jul 2004 22:59:19 GMT
User-agent: KNode/0.7.7

Peter Gunreben wrote:

> Hi,
> 
> how can I get rid of the following warning:
> 
> ==========%<=============
> #include <vector>
> #include <complex>
> 
> typedef std::complex<double> mycomplex;
> 
> int main() {
> 
>    std::vector<mycomplex> a(1);
>    a[0] = mycomplex(2.,0.); // Here's the warning
> 
>    return(0);
> }
> ==========%<=============
> 
>  g++ -W -Wall -Wsynth example.cc
> 
> example.cc: In function `int main()':
> example.cc:10: warning: using synthesized
> `std::complex<double>& std::complex<double>::operator=(const
> std::complex<double>&)' for copy assignment
> gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/complex:998:
> warning:   where cfront would use
> `std::complex<double>& std::complex<double>::operator=(const
> std::complex<_Tp>&) [with _Tp = double]'

Dig out the complex<> headers. Sounds like a convoluted way of saying g++
hasn't implemented assignment operator because it can produce it on demand.
I haven't checked btw.

std::vector<mycomplex> a(mycomplex(2,0));

...avoids it (cctor). This approach probably would as well...

struct mycomplex : public std::complex<double>
{
 //...
 mycomplex(double a_,double b_)
 : std::complex<double>(a_,b_)
 {}
};

...not too nice - easier to lose -WSynth at that point perhaps?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]