Date
2010-10-21.18:28:33
Message id
2438

Content

Proposed resolution:

Add the following requirements to [complex.numbers] as 26.3/4:

If z is an lvalue expression of type cv std::complex<T> then

  • the expression reinterpret_cast<cv T(&)[2]>(z) is well-formed; and
  • reinterpret_cast<cv T(&)[2]>(z)[0] designates the real part of z; and
  • reinterpret_cast<cv T(&)[2]>(z)[1] designates the imaginary part of z.

Moreover, if a is an expression of pointer type cv complex<T>* and the expression a[i] is well-defined for an integer expression i then:

  • reinterpret_cast<cv T*>(a)[2*i] designates the real part of a[i]; and
  • reinterpret_cast<cv T*>(a)[2*i+1] designates the imaginary part of a[i].

In [complex] and [complex.special] add the following member functions (changing T to concrete types as appropriate for the specializations).

void real(T);
void imag(T);

Add to [complex.members]

T real() const;

Returns: the value of the real component

void real(T val);

Assigns val to the real component.

T imag() const;

Returns: the value of the imaginary component

void imag(T val);

Assigns val to the imaginary component.