Started to make the IndexList code compile by more compilers

This commit is contained in:
Benoit Steiner 2015-11-12 16:41:14 -08:00
parent 7a1316fcc5
commit e9ecfad796
3 changed files with 29 additions and 25 deletions

View File

@ -72,14 +72,14 @@ struct all_indices_known_statically<const DimensionList<Index, Rank> > {
}; };
template <typename Index, std::size_t Rank> template <typename Index, std::size_t Rank>
struct indices_statically_known_to_increase<DimensionList<Index, Rank> > { struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
constexpr bool operator() () const { static constexpr bool run() {
return true; return true;
} }
}; };
template <typename Index, std::size_t Rank> template <typename Index, std::size_t Rank>
struct indices_statically_known_to_increase<const DimensionList<Index, Rank> > { struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
constexpr bool operator() () const { static constexpr bool run() {
return true; return true;
} }
}; };
@ -164,14 +164,14 @@ struct all_indices_known_statically<const DimensionList<Index, Rank> > {
}; };
template <typename Index, std::size_t Rank> template <typename Index, std::size_t Rank>
struct indices_statically_known_to_increase<DimensionList<Index, Rank> > { struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
EIGEN_ALWAYS_INLINE bool operator() () const { static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
return true; return true;
} }
}; };
template <typename Index, std::size_t Rank> template <typename Index, std::size_t Rank>
struct indices_statically_known_to_increase<const DimensionList<Index, Rank> > { struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
EIGEN_ALWAYS_INLINE bool operator() () const { static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
return true; return true;
} }
}; };

View File

@ -336,26 +336,32 @@ struct all_indices_known_statically<const IndexList<FirstType, OtherTypes...> >
}; };
template <typename T> template <typename T>
struct indices_statically_known_to_increase { struct indices_statically_known_to_increase_impl {
constexpr bool operator() () const { static constexpr bool run() {
return false; return false;
} }
}; };
template <typename FirstType, typename... OtherTypes> template <typename FirstType, typename... OtherTypes>
struct indices_statically_known_to_increase<IndexList<FirstType, OtherTypes...> > { struct indices_statically_known_to_increase_impl<IndexList<FirstType, OtherTypes...> > {
constexpr bool operator() () const { static constexpr bool run() {
return IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase(); return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
} }
}; };
template <typename FirstType, typename... OtherTypes> template <typename FirstType, typename... OtherTypes>
struct indices_statically_known_to_increase<const IndexList<FirstType, OtherTypes...> > { struct indices_statically_known_to_increase_impl<const IndexList<FirstType, OtherTypes...> > {
constexpr bool operator() () const { static constexpr bool run() {
return IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase(); return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
} }
}; };
template <typename T>
static constexpr bool indices_statically_known_to_increase() {
return indices_statically_known_to_increase_impl<T>::run();
}
template <typename Tx> template <typename Tx>
struct index_statically_eq { struct index_statically_eq {
constexpr bool operator() (DenseIndex, DenseIndex) const { constexpr bool operator() (DenseIndex, DenseIndex) const {
@ -473,11 +479,9 @@ struct all_indices_known_statically {
}; };
template <typename T> template <typename T>
struct indices_statically_known_to_increase { static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_known_to_increase() {
EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() () const { return false;
return false; }
}
};
template <typename T> template <typename T>
struct index_statically_eq { struct index_statically_eq {

View File

@ -88,14 +88,14 @@ struct preserve_inner_most_dims {
#if defined(EIGEN_HAS_CONSTEXPR) && defined(EIGEN_HAS_VARIADIC_TEMPLATES) #if defined(EIGEN_HAS_CONSTEXPR) && defined(EIGEN_HAS_VARIADIC_TEMPLATES)
template <typename ReducedDims, int NumTensorDims> template <typename ReducedDims, int NumTensorDims>
struct are_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{ struct are_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{
static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>()(); static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>();
static const bool tmp2 = index_statically_eq<ReducedDims>()(0, 0); static const bool tmp2 = index_statically_eq<ReducedDims>()(0, 0);
static const bool tmp3 = index_statically_eq<ReducedDims>()(array_size<ReducedDims>::value-1, array_size<ReducedDims>::value-1); static const bool tmp3 = index_statically_eq<ReducedDims>()(array_size<ReducedDims>::value-1, array_size<ReducedDims>::value-1);
static const bool value = tmp1 & tmp2 & tmp3; static const bool value = tmp1 & tmp2 & tmp3;
}; };
template <typename ReducedDims, int NumTensorDims> template <typename ReducedDims, int NumTensorDims>
struct are_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{ struct are_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{
static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>()(); static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>();
static const bool tmp2 = index_statically_eq<ReducedDims>()(0, NumTensorDims - array_size<ReducedDims>::value); static const bool tmp2 = index_statically_eq<ReducedDims>()(0, NumTensorDims - array_size<ReducedDims>::value);
static const bool tmp3 = index_statically_eq<ReducedDims>()(array_size<ReducedDims>::value - 1, NumTensorDims - 1); static const bool tmp3 = index_statically_eq<ReducedDims>()(array_size<ReducedDims>::value - 1, NumTensorDims - 1);
static const bool value = tmp1 & tmp2 & tmp3; static const bool value = tmp1 & tmp2 & tmp3;
@ -103,14 +103,14 @@ struct are_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{
}; };
template <typename ReducedDims, int NumTensorDims> template <typename ReducedDims, int NumTensorDims>
struct preserve_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{ struct preserve_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{
static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>()(); static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>();
static const bool tmp2 = index_statically_gt<ReducedDims>()(0, 0); static const bool tmp2 = index_statically_gt<ReducedDims>()(0, 0);
static const bool value = tmp1 & tmp2; static const bool value = tmp1 & tmp2;
}; };
template <typename ReducedDims, int NumTensorDims> template <typename ReducedDims, int NumTensorDims>
struct preserve_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{ struct preserve_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{
static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>()(); static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>();
static const bool tmp2 = index_statically_lt<ReducedDims>()(array_size<ReducedDims>::value - 1, NumTensorDims - 1); static const bool tmp2 = index_statically_lt<ReducedDims>()(array_size<ReducedDims>::value - 1, NumTensorDims - 1);
static const bool value = tmp1 & tmp2; static const bool value = tmp1 & tmp2;
}; };