Skip to content

Make fixed-size Matrix and Array trivially copyable after C++20

Making them trivially copyable allows using std::memcpy() without undefined behaviors.

Only Matrix and Array with trivially copyable DenseStorage are marked as trivially copyable with an additional type trait.

As described in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0848r3.html it requires extremely verbose SFINAE to make the special member functions of fixed-size Matrix and Array trivial, unless C++20 concepts are available to simplify the selection of trivial special member functions given template parameters. Therefore only make this feature available to compilers that support C++20 P0848R3.

Fix #1855.

I have run the official and unsupported tests locally with passing results using the same commands in ci/test.gitlab-ci.yml and cmake -DCMAKE_CXX_STANDARD=20, but it's not clear to me how the CI script itself should be updated.

Please also let me know if any documentation is needed.

Edited by Lingzhu Xiang

Merge request reports

Loading