Disable AutoDiffScalar generic copy ctor for non compatible scalar types (fix ambiguous template instantiation)

This commit is contained in:
Gael Guennebaud 2015-12-16 10:14:24 +01:00
parent 92655e7215
commit 35d8725c73

14
unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h Normal file → Executable file
View File

@ -99,7 +99,11 @@ class AutoDiffScalar
{}
template<typename OtherDerType>
AutoDiffScalar(const AutoDiffScalar<OtherDerType>& other)
AutoDiffScalar(const AutoDiffScalar<OtherDerType>& other
#ifndef EIGEN_PARSED_BY_DOXYGEN
, typename internal::enable_if<internal::is_same<Scalar,typename OtherDerType::Scalar>::value,void*>::type = 0
#endif
)
: m_value(other.value()), m_derivatives(other.derivatives())
{}
@ -127,6 +131,14 @@ class AutoDiffScalar
return *this;
}
inline AutoDiffScalar& operator=(const Scalar& other)
{
m_value = other;
if(m_derivatives.size()>0)
m_derivatives.setZero();
return *this;
}
// inline operator const Scalar& () const { return m_value; }
// inline operator Scalar& () { return m_value; }