diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-09-06 15:47:04 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-09-06 15:47:04 +0200 |
commit | b046a3f87d90d0f815dc03b9fdfcb1fda32504fb (patch) | |
tree | 8e06d215e2096ed4683456cf74a165cbaadf68d5 /Eigen/src/Core | |
parent | 3cb914f33285f25de4b3e34ca33bbebc3e0a55d3 (diff) |
Workaround MSVC instantiation faillure of has_*ary_operator at the level of triats<Ref>::match so that the has_*ary_operator are really properly instantiated throughout the compilation unit.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/CoreEvaluators.h | 34 | ||||
-rw-r--r-- | Eigen/src/Core/Ref.h | 8 |
2 files changed, 24 insertions, 18 deletions
diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index c5ad37847..ece8c0fcf 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -393,9 +393,9 @@ struct nullary_wrapper<Scalar,NullaryOp,false,true,false> template<typename Scalar,typename NullaryOp> struct nullary_wrapper<Scalar,NullaryOp,false,false,false> {}; -#if EIGEN_COMP_MSVC>0 && EIGEN_COMP_MSVC<=1700 +#if EIGEN_COMP_MSVC>0 -// MSVC 2012 (and probably older ones too) exhibits a weird compilation error when +// MSVC exhibits a weird compilation error when // compiling: // Eigen::MatrixXf A = MatrixXf::Random(3,3); // Ref<const MatrixXf> R = 2.f*A; @@ -408,8 +408,8 @@ struct nullary_wrapper<Scalar,NullaryOp,false,false,false> {}; // This is a simple wrapper around Index to enforce the re-instantiation of // has_*ary_operator when needed. -template<typename T> struct nullary_wrapper_workaround_msvc_2012 { - nullary_wrapper_workaround_msvc_2012(const T&); +template<typename T> struct nullary_wrapper_workaround_msvc { + nullary_wrapper_workaround_msvc(const T&); operator T()const; }; @@ -419,34 +419,34 @@ struct nullary_wrapper<Scalar,NullaryOp,true,true,true> template <typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const { return nullary_wrapper<Scalar,NullaryOp, - has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value>().operator()(op,i,j); + has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i,j); } template <typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return nullary_wrapper<Scalar,NullaryOp, - has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value>().operator()(op,i); + has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i); } template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const { return nullary_wrapper<Scalar,NullaryOp, - has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value>().template packetOp<T>(op,i,j); + has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().template packetOp<T>(op,i,j); } template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const { return nullary_wrapper<Scalar,NullaryOp, - has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value, - has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc_2012<IndexType> >::value>().template packetOp<T>(op,i); + has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value, + has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().template packetOp<T>(op,i); } }; -#endif // MSVC<=2012 workaround +#endif // MSVC workaround template<typename NullaryOp, typename PlainObjectType> struct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> > diff --git a/Eigen/src/Core/Ref.h b/Eigen/src/Core/Ref.h index 17065fdd5..bdf24f52a 100644 --- a/Eigen/src/Core/Ref.h +++ b/Eigen/src/Core/Ref.h @@ -35,7 +35,13 @@ struct traits<Ref<_PlainObjectType, _Options, _StrideType> > || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1), OuterStrideMatch = Derived::IsVectorAtCompileTime || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime), - AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (int(evaluator<Derived>::Alignment) >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment + // NOTE, this indirection of evaluator<Derived>::Alignment is needed + // to workaround a very strange bug in MSVC related to the instantiation + // of has_*ary_operator in evaluator<CwiseNullaryOp>. + // This line is surprisingly very sensitive. For instance, simply adding parenthesis + // as "DerivedAlignment = (int(evaluator<Derived>::Alignment))," will make MSVC fail... + DerivedAlignment = int(evaluator<Derived>::Alignment), + AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (DerivedAlignment >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment ScalarTypeMatch = internal::is_same<typename PlainObjectType::Scalar, typename Derived::Scalar>::value, MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch }; |