mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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.
This commit is contained in:
committed by
David Tellenbach
parent
c4b1dd2f6b
commit
47eac21072
@@ -20,6 +20,11 @@ static_assert(std::is_trivially_move_assignable<DenseStorageD3x3>::value, "Dense
|
||||
static_assert(std::is_trivially_copy_constructible<DenseStorageD3x3>::value, "DenseStorage not trivially_copy_constructible");
|
||||
static_assert(std::is_trivially_copy_assignable<DenseStorageD3x3>::value, "DenseStorage not trivially_copy_assignable");
|
||||
static_assert(std::is_trivially_copyable<DenseStorageD3x3>::value, "DenseStorage not trivially_copyable");
|
||||
#if EIGEN_COMP_HAS_P0848R3
|
||||
static_assert(std::is_trivially_copyable<Eigen::Matrix3d>::value, "Eigen::Matrix3d not trivially_copyable");
|
||||
static_assert(std::is_trivially_copyable<Eigen::Array33d>::value, "Eigen::Array33d not trivially_copyable");
|
||||
static_assert(!std::is_trivially_copyable<Eigen::Matrix3<AnnoyingScalar>>::value, "Eigen::Matrix3<AnnoyingScalar> is trivially_copyable");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <typename T, int Size, int Rows, int Cols>
|
||||
|
||||
Reference in New Issue
Block a user