Compile- and run-time assertions for the construction of Ref<const>.

This commit is contained in:
wilfried.karel
2023-06-14 15:49:58 +00:00
committed by Rasmus Munk Larsen
parent 59b3ef5409
commit d8f3eb87bf
4 changed files with 50 additions and 1 deletions

View File

@@ -36,6 +36,8 @@ ei_add_failtest("ref_2")
ei_add_failtest("ref_3")
ei_add_failtest("ref_4")
ei_add_failtest("ref_5")
ei_add_failtest("ref_6")
ei_add_failtest("ref_7")
ei_add_failtest("swap_1")
ei_add_failtest("swap_2")

15
failtest/ref_6.cpp Normal file
View File

@@ -0,0 +1,15 @@
#include "../Eigen/Core"
using namespace Eigen;
void call_ref(Ref<const VectorXf, 0, InnerStride<2>>) {}
int main() {
VectorXf a(10);
Map<const VectorXf, 0, InnerStride<2>> m(a.data(), 5);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(a);
#else
call_ref(m);
#endif
}

16
failtest/ref_7.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include "../Eigen/Core"
using namespace Eigen;
void call_ref(Ref<const Matrix3f, 0, OuterStride<2>>) {}
int main() {
MatrixXf a(6, 2);
Map<const Matrix3f, 0, OuterStride<Dynamic>> md(a.data(), OuterStride<Dynamic>(2));
Map<const Matrix3f, 0, OuterStride<2>> m2(a.data());
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
call_ref(md);
#else
call_ref(m2);
#endif
}