This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Why do gcc's std::real() and std::imag() return references?
- From: Randalph Phelps <senland at yahoo dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 16 Jun 2011 17:27:49 -0700 (PDT)
- Subject: Why do gcc's std::real() and std::imag() return references?
- Reply-to: Randalph Phelps <senland at yahoo dot com>
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