Workaround weird MSVC bug

This commit is contained in:
Gael Guennebaud 2018-11-21 15:53:37 +01:00
parent 0ec8afde57
commit 4b2cebade8
2 changed files with 18 additions and 1 deletions

View File

@ -180,8 +180,10 @@ public:
RealScalar threshold() const
{
eigen_assert(m_isInitialized || m_usePrescribedThreshold);
// this temporary is needed to workaround a MSVC issue
Index diagSize = (std::max<Index>)(1,m_diagSize);
return m_usePrescribedThreshold ? m_prescribedThreshold
: (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon();
: diagSize*NumTraits<Scalar>::epsilon();
}
/** \returns true if \a U (full or thin) is asked for in this SVD decomposition */

View File

@ -57,6 +57,19 @@ void jacobi(const MatrixType& m = MatrixType())
}
}
namespace Foo {
class Bar {};
bool operator<(const Bar&, const Bar&) { return true; }
}
// regression test for a very strange MSVC issue for which simply
// including SVDBase.h messes up with std::max and custom scalar type
void msvc_workaround()
{
const Foo::Bar a;
const Foo::Bar b;
std::max EIGEN_NOT_A_MACRO (a,b);
}
EIGEN_DECLARE_TEST(jacobi)
{
for(int i = 0; i < g_repeat; i++) {
@ -77,4 +90,6 @@ EIGEN_DECLARE_TEST(jacobi)
TEST_SET_BUT_UNUSED_VARIABLE(r);
TEST_SET_BUT_UNUSED_VARIABLE(c);
}
msvc_workaround();
}