Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialize xtl::xcomplex for non references #253

Open
JohanMabille opened this issue Jul 20, 2021 · 0 comments
Open

Specialize xtl::xcomplex for non references #253

JohanMabille opened this issue Jul 20, 2021 · 0 comments

Comments

@JohanMabille
Copy link
Member

JohanMabille commented Jul 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant