From 60400334a92268272c6bf525da89eec5e99c3e5a Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 30 Jun 2021 04:27:51 +0000 Subject: Make DenseStorage<> trivially_copyable --- Eigen/src/Core/DenseStorage.h | 13 +++++++++++++ test/dense_storage.cpp | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index 9acca6c90..8a4cbd4be 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -214,17 +214,26 @@ template class DenseSt EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()) {} +#if !EIGEN_HAS_CXX11 || defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN) EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size) } +#else + EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) = default; +#endif +#if !EIGEN_HAS_CXX11 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) { if (this != &other) m_data = other.m_data; return *this; } +#else + EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) = default; +#endif #if EIGEN_HAS_RVALUE_REFERENCES +#if !EIGEN_HAS_CXX11 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT : m_data(std::move(other.m_data)) { @@ -235,6 +244,10 @@ template class DenseSt m_data = std::move(other.m_data); return *this; } +#else + EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT = default; + EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT = default; +#endif #endif EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({}) diff --git a/test/dense_storage.cpp b/test/dense_storage.cpp index 36ccbb02c..45c2bd728 100644 --- a/test/dense_storage.cpp +++ b/test/dense_storage.cpp @@ -13,6 +13,17 @@ #include +#if EIGEN_HAS_TYPE_TRAITS && EIGEN_HAS_CXX11 +using DenseStorageD3x3 = Eigen::DenseStorage; +static_assert(std::is_trivially_move_constructible::value, "DenseStorage not trivially_move_constructible"); +static_assert(std::is_trivially_move_assignable::value, "DenseStorage not trivially_move_assignable"); +#if !defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN) +static_assert(std::is_trivially_copy_constructible::value, "DenseStorage not trivially_copy_constructible"); +static_assert(std::is_trivially_copy_assignable::value, "DenseStorage not trivially_copy_assignable"); +static_assert(std::is_trivially_copyable::value, "DenseStorage not trivially_copyable"); +#endif +#endif + template void dense_storage_copy(int rows, int cols) { -- cgit v1.2.3