From 722916e19d86b224ec6c705e24d376def524154b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 6 Nov 2014 09:25:26 +0100 Subject: bug #903: clean swap API regarding extra enable_if parameters, and add failtests for swap --- failtest/CMakeLists.txt | 3 +++ failtest/swap_1.cpp | 14 ++++++++++++++ failtest/swap_2.cpp | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 failtest/swap_1.cpp create mode 100644 failtest/swap_2.cpp (limited to 'failtest') diff --git a/failtest/CMakeLists.txt b/failtest/CMakeLists.txt index 5343dc152..d2fea7bdc 100644 --- a/failtest/CMakeLists.txt +++ b/failtest/CMakeLists.txt @@ -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. " diff --git a/failtest/swap_1.cpp b/failtest/swap_1.cpp new file mode 100644 index 000000000..106379720 --- /dev/null +++ b/failtest/swap_1.cpp @@ -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 &ac(a); +#else + DenseBase &ac(a); +#endif + b.swap(ac); +} diff --git a/failtest/swap_2.cpp b/failtest/swap_2.cpp new file mode 100644 index 000000000..c130ba6e4 --- /dev/null +++ b/failtest/swap_2.cpp @@ -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 +} \ No newline at end of file -- cgit v1.2.3