xtl icon indicating copy to clipboard operation
xtl copied to clipboard

Specialize xtl::xcomplex for non references

Open JohanMabille opened this issue 4 years ago • 0 comments

The current implementation of xtl::xcomplex prevents to reinterpret_cast it into an array of the underlying value_type, like one can do with std::complex (see http://eel.is/c++draft/complex.numbers.general). This is because xtl::complex stores the real and imaginay parts as two double. Even if this is almost always possible to reinterpret cast such a structure into an array, it is undefined behavior according to the standard.

A fix would be to specialize the implementation of xtl::xcomplex when its template parameters are not references. This would be a backward compatible change since only the storage of the data would change, not the APIs.

cc @serge-sans-paille

JohanMabille avatar Jul 20 '21 14:07 JohanMabille