mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Big 853: replace enable_if in Ref<> ctor by static assertions and add failtests for Ref<>
This commit is contained in:
@@ -26,6 +26,12 @@ ei_add_failtest("block_on_const_type_actually_const_1")
|
||||
ei_add_failtest("transpose_on_const_type_actually_const")
|
||||
ei_add_failtest("diagonal_on_const_type_actually_const")
|
||||
|
||||
ei_add_failtest("ref_1")
|
||||
ei_add_failtest("ref_2")
|
||||
ei_add_failtest("ref_3")
|
||||
ei_add_failtest("ref_4")
|
||||
ei_add_failtest("ref_5")
|
||||
|
||||
if (EIGEN_FAILTEST_FAILURE_COUNT)
|
||||
message(FATAL_ERROR
|
||||
"${EIGEN_FAILTEST_FAILURE_COUNT} out of ${EIGEN_FAILTEST_COUNT} failtests FAILED. "
|
||||
|
||||
18
failtest/ref_1.cpp
Normal file
18
failtest/ref_1.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "../Eigen/Core"
|
||||
|
||||
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
|
||||
#define CV_QUALIFIER const
|
||||
#else
|
||||
#define CV_QUALIFIER
|
||||
#endif
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
void call_ref(Ref<VectorXf> a) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
VectorXf a(10);
|
||||
CV_QUALIFIER VectorXf& ac(a);
|
||||
call_ref(ac);
|
||||
}
|
||||
15
failtest/ref_2.cpp
Normal file
15
failtest/ref_2.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../Eigen/Core"
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
void call_ref(Ref<VectorXf> a) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
MatrixXf A(10,10);
|
||||
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
|
||||
call_ref(A.row(3));
|
||||
#else
|
||||
call_ref(A.col(3));
|
||||
#endif
|
||||
}
|
||||
15
failtest/ref_3.cpp
Normal file
15
failtest/ref_3.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../Eigen/Core"
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
|
||||
void call_ref(Ref<VectorXf> a) { }
|
||||
#else
|
||||
void call_ref(const Ref<const VectorXf> &a) { }
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
VectorXf a(10);
|
||||
call_ref(a+a);
|
||||
}
|
||||
15
failtest/ref_4.cpp
Normal file
15
failtest/ref_4.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../Eigen/Core"
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
void call_ref(Ref<MatrixXf,0,OuterStride<> > a) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
MatrixXf A(10,10);
|
||||
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
|
||||
call_ref(A.transpose());
|
||||
#else
|
||||
call_ref(A);
|
||||
#endif
|
||||
}
|
||||
16
failtest/ref_5.cpp
Normal file
16
failtest/ref_5.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../Eigen/Core"
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
void call_ref(Ref<VectorXf> a) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
VectorXf a(10);
|
||||
DenseBase<VectorXf> &ac(a);
|
||||
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
|
||||
call_ref(ac);
|
||||
#else
|
||||
call_ref(ac.derived());
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user