From: Ian Scott <ian.scott@st...>  20080924 16:36:47

Laflen, Brandon (GE, Research, consultant) wrote: > Dear vxl maintainers, > > I've run afoul of a difference in the implementation of std::complex, > which appears to propagate to vcl_complex. > > In GNU c++, the STL complex defines member functions real (and similarly > imag) such: > > /// Return real part of complex number. > _Tp& real(); > > /// Return real part of complex number. > const _Tp& real() const; According to both C++98 and the current C++0x draft, these are not part of the standard. Page 568 defines the members of class complex<T> as including T real() const; T imag() const; > > In MSVC8, the STL complex defines member functions real (and similarly > imag) such: > > _Ty real(const _Ty& _Right) > { // set real component > return (this>_Val[_RE] = _Right); > } This isn't in C++98 but is in C++0xdraft > In the GNU implementation, the real part is assigned thus: > > x.real() = c; > > In the MSVC8 implementation, the real part is assigned thus: > > x.real( c ); Neither of the above is C++ according to the C++98 standard. You simply can't directly modify one component  presumably to allow for differing representations. The coming version of C++ explicitly requires a [real, imaginary] layout, in which case your MSVC8 example above will work. I suspect that you are supposed to write code such as x=vcl_complex<double>(c, x.imag()); > > On both platforms, vcl_complex appears to be defined as std::complex, so > this implementation difference propagates into vcl_complex. > > Am I missing something here, or is vcl_complex failing to enforce a > standard, crossplatform implementation? vcl enables you to write standard* C++ across multiple platforms. For example it corrects various platforms very dodgy implementation of pow(complex, complex). It doesn't attempt to standardise implementationspecified additional features Upgrading vcl to support C++0x is a task that has barely begun. Quite frankly I doubt we will get there until at least GCC or MSVC support the vast majority of C++0x. Hope this helps. Ian *  subject to the s/std::/vcl/ translation, and the increasingly unnecessary #ifdef VCL_DOES_MY_COMPILER_SUPPORT_CORE_BITS_OF_THE_LANGUAGE. 