mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
make fixed size matrices and arrays trivially_default_constructible
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
b396a6fbb2
commit
4e5136d239
@@ -7,13 +7,20 @@
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#define EIGEN_TESTING_PLAINOBJECT_CTOR
|
||||
|
||||
#ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#define EIGEN_TEST_REENABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "AnnoyingScalar.h"
|
||||
#include "SafeScalar.h"
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
using DenseStorageD3x3 = Eigen::DenseStorage<double, 3, 3, 3, 3>;
|
||||
using DenseStorageD3x3 = Eigen::DenseStorage<double, 9, 3, 3, 0>;
|
||||
static_assert(std::is_trivially_move_constructible<DenseStorageD3x3>::value,
|
||||
"DenseStorage not trivially_move_constructible");
|
||||
static_assert(std::is_trivially_move_assignable<DenseStorageD3x3>::value, "DenseStorage not trivially_move_assignable");
|
||||
@@ -24,6 +31,14 @@ static_assert(std::is_trivially_copy_assignable<DenseStorageD3x3>::value, "Dense
|
||||
static_assert(std::is_trivially_copyable<DenseStorageD3x3>::value, "DenseStorage not trivially_copyable");
|
||||
#endif
|
||||
|
||||
static_assert(std::is_trivially_move_constructible<Matrix4f>::value, "Matrix4f not trivially_move_constructible");
|
||||
#if !defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN)
|
||||
static_assert(std::is_trivially_copy_constructible<Matrix4f>::value, "Matrix4f not trivially_copy_constructible");
|
||||
#endif
|
||||
#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
|
||||
static_assert(std::is_trivially_default_constructible<Matrix4f>::value, "Matrix4f not trivially_default_constructible");
|
||||
#endif
|
||||
|
||||
template <typename T, int Size, int Rows, int Cols>
|
||||
void dense_storage_copy(int rows, int cols) {
|
||||
typedef DenseStorage<T, Size, Rows, Cols, 0> DenseStorageType;
|
||||
@@ -180,3 +195,9 @@ EIGEN_DECLARE_TEST(dense_storage) {
|
||||
dense_storage_tests<SafeScalar<float> >();
|
||||
dense_storage_tests<AnnoyingScalar>();
|
||||
}
|
||||
|
||||
#undef EIGEN_TESTING_PLAINOBJECT_CTOR
|
||||
#ifdef EIGEN_TEST_REENABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#undef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#undef EIGEN_TEST_REENABLE_UNALIGNED_ARRAY_ASSERT
|
||||
#endif
|
||||
|
||||
12
test/main.h
12
test/main.h
@@ -142,14 +142,20 @@ struct imag {};
|
||||
static long int nb_temporaries;
|
||||
static long int nb_temporaries_on_assert = -1;
|
||||
|
||||
inline void on_temporary_creation(long int size) {
|
||||
#ifdef TEST_IGNORE_STACK_ALLOCATED_TEMPORARY
|
||||
inline void on_temporary_creation(long int size, int SizeAtCompileTime) {
|
||||
// ignore stack-allocated temporaries
|
||||
if (SizeAtCompileTime != -1) return;
|
||||
#else
|
||||
inline void on_temporary_creation(long int size, int) {
|
||||
#endif
|
||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
||||
if (size != 0) nb_temporaries++;
|
||||
if (nb_temporaries_on_assert > 0) assert(nb_temporaries < nb_temporaries_on_assert);
|
||||
}
|
||||
|
||||
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN \
|
||||
{ on_temporary_creation(size); }
|
||||
{ on_temporary_creation(size, Size); }
|
||||
|
||||
#define VERIFY_EVALUATION_COUNT(XPR, N) \
|
||||
{ \
|
||||
@@ -333,7 +339,7 @@ static std::vector<std::string> eigen_assert_list;
|
||||
|
||||
#endif // EIGEN_NO_ASSERTION_CHECKING
|
||||
|
||||
#ifndef EIGEN_TESTING_CONSTEXPR
|
||||
#if !defined(EIGEN_TESTING_CONSTEXPR) && !defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
|
||||
#define EIGEN_INTERNAL_DEBUGGING
|
||||
#endif
|
||||
#include <Eigen/QR> // required for createRandomPIMatrixOfRank and generateRandomMatrixSvs
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#define TEST_ENABLE_TEMPORARY_TRACKING
|
||||
#define TEST_IGNORE_STACK_ALLOCATED_TEMPORARY
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user