From 8fe609311d696189d443f42877a09fdf931220b4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 7 Nov 2013 09:01:26 +0100 Subject: [PATCH] Move internal::swap to numext to fix ambiguous call with std::swap --- Eigen/src/Core/util/Meta.h | 14 +++++++++++--- Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index aea168b46..e4e4d4a87 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -89,9 +89,9 @@ template struct enable_if { typedef T type; }; #if defined(__CUDA_ARCH__) -template EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; } namespace device { + template struct numeric_limits { EIGEN_DEVICE_FUNC @@ -110,8 +110,6 @@ template<> struct numeric_limits } -#else -template EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); } #endif /** \internal @@ -262,6 +260,16 @@ template struct is_diagonal > } // end namespace internal +namespace numext { + +#if defined(__CUDA_ARCH__) +template EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; } +#else +template EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); } +#endif + +} // end namespace numext + } // end namespace Eigen #endif // EIGEN_META_H diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index be2f7b452..0c3425069 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -606,12 +606,12 @@ template struct direct_selfadjoint_eigenvalues= roots(1)) - internal::swap(roots(0),roots(1)); + numext::swap(roots(0),roots(1)); if (roots(1) >= roots(2)) { - internal::swap(roots(1),roots(2)); + numext::swap(roots(1),roots(2)); if (roots(0) >= roots(1)) - internal::swap(roots(0),roots(1)); + numext::swap(roots(0),roots(1)); } }