This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why do gcc's std::real() and std::imag() return references?


Hi all,

I have noticed that gcc's std::real() and std::imag() return a reference, unless 
"-std=c++0x" is specified. The C++98 standard specifies in section 26.2.7 that 
these two functions have the following prototypes:

template<class T> T real(const complex<T>&);
template<class T> T imag(const complex<T>&);

In gcc 4.4, for example, it is:
template<typename _Tp> _Tp& real(complex<_Tp>& __z)

Is there a reason for this deviation from the standard? This breaks for any 
specializations of std::complex that return a value for real() and imag().

Thanks,
- Rudy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]