N3797 26.4 [complex.numbers] says this about casting std::complex<T>* to T*
4 Moreover, if a is an expression of type
cv std::complex<T>*and the expressiona[i]is well-defined for an integer expressioni, then:
-reinterpret_cast<cv T*>(a)[2*i]shall designate the real part ofa[i], and
-reinterpret_cast<cv T*>(a)[2*i + 1]shall designate the imaginary part ofa[i].
Does this (or some other wording of the standard) imply that I can reinterpret_cast the other way? Can I do this:
float * pf;
std::complex<float>* pc = reinterpret_cast<std::complex<float>*>(pf);
pc[i].real();
As n.m. pointed out below, I would have to make sure the alignment of pf is suitable for a std::complex<float>. This can be assumed to be taken care of.