| std::complex standard packing requirements was Re: [eigen] FFT for Eigen |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
|
I had this discussion a few years ago on comp.lang.c++ when I was
trying to share complex buffers between c99 libs and C++ apps. The bottom line is that the original C++ ISO standard did not require array[2] packing for std::complex, but that requirement was in the standards pipeline and all sane compilers already do it. http://www.cpptalk.net/portable-complex-numbers-between-c-c--vt46432.html http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#387 It should be safe enough to go down that path, but it would still be good to add a compile time check to ensure sizeof( std::complex<T> ) == 2*sizeof(T) and a runtime check for &cpx.imag() - &cpx.real() == 1 -- Mark Benoit Jacob wrote: I'm OK if this doesn't crash. If the STL clearly specifies that the two coords in a complex<> are stored as an array, then it's OK. If on the other hand, some implementation stores the 2 coordinates as just 2 separate members, and someone compiles this with a strict 64 bit alignment, then with complex<float> that will crash. Benoit 2009/5/19 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>: |
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |