diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-07-03 13:21:43 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-07-03 13:21:43 +0200 |
commit | 3ae2083e230ec9517cb9b40d1137dec7ba4b2b17 (patch) | |
tree | 96a664523a50e06e49d2d8311f467b8492a038e7 /Eigen/src/Core/util | |
parent | 67ec37f7b0d9ccaaede508109e50528138eaf4d8 (diff) |
Make is_same_dense compatible with different scalar types.
Diffstat (limited to 'Eigen/src/Core/util')
-rw-r--r-- | Eigen/src/Core/util/XprHelper.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 16714fa5c..f7a3d9ce7 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -680,13 +680,18 @@ template<typename S1, typename S2> struct glue_shapes; template<> struct glue_shapes<DenseShape,TriangularShape> { typedef TriangularShape type; }; template<typename T1, typename T2> -bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if<has_direct_access<T1>::ret&&has_direct_access<T2>::ret, T1>::type * = 0) +struct possibly_same_dense { + enum { value = has_direct_access<T1>::ret && has_direct_access<T2>::ret && is_same<typename T1::Scalar,typename T2::Scalar>::value }; +}; + +template<typename T1, typename T2> +bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if<possibly_same_dense<T1,T2>::value>::type * = 0) { return (mat1.data()==mat2.data()) && (mat1.innerStride()==mat2.innerStride()) && (mat1.outerStride()==mat2.outerStride()); } template<typename T1, typename T2> -bool is_same_dense(const T1 &, const T2 &, typename enable_if<!(has_direct_access<T1>::ret&&has_direct_access<T2>::ret), T1>::type * = 0) +bool is_same_dense(const T1 &, const T2 &, typename enable_if<!possibly_same_dense<T1,T2>::value>::type * = 0) { return false; } |