bug #903: clean swap API regarding extra enable_if parameters, and add failtests for swap

This commit is contained in:
Gael Guennebaud
2014-11-06 09:25:26 +01:00
parent c6fefe5d8e
commit 722916e19d
9 changed files with 61 additions and 31 deletions

View File

@@ -38,6 +38,9 @@ ei_add_failtest("ref_3")
ei_add_failtest("ref_4")
ei_add_failtest("ref_5")
ei_add_failtest("swap_1")
ei_add_failtest("swap_2")
if (EIGEN_FAILTEST_FAILURE_COUNT)
message(FATAL_ERROR
"${EIGEN_FAILTEST_FAILURE_COUNT} out of ${EIGEN_FAILTEST_COUNT} failtests FAILED. "

14
failtest/swap_1.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "../Eigen/Core"
using namespace Eigen;
int main()
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
const DenseBase<VectorXf> &ac(a);
#else
DenseBase<VectorXf> &ac(a);
#endif
b.swap(ac);
}

14
failtest/swap_2.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "../Eigen/Core"
using namespace Eigen;
int main()
{
VectorXf a(10), b(10);
VectorXf const &ac(a);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b.swap(ac);
#else
b.swap(ac.const_cast_derived());
#endif
}