mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-14 20:56:00 +08:00
Complete previous backport with is_valid_index_type
This commit is contained in:
parent
441b3511de
commit
dd93c41618
@ -396,6 +396,20 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Does the compiler support type_traits?
|
||||||
|
// - full support of type traits was added only to GCC 5.1.0.
|
||||||
|
// - 20150626 corresponds to the last release of 4.x libstdc++
|
||||||
|
#ifndef EIGEN_HAS_TYPE_TRAITS
|
||||||
|
#if EIGEN_MAX_CPP_VER>=11 && (EIGEN_HAS_CXX11 || EIGEN_COMP_MSVC >= 1700) \
|
||||||
|
&& ((!EIGEN_COMP_GNUC_STRICT) || EIGEN_GNUC_AT_LEAST(5, 1)) \
|
||||||
|
&& ((!defined(__GLIBCXX__)) || __GLIBCXX__ > 20150626)
|
||||||
|
#define EIGEN_HAS_TYPE_TRAITS 1
|
||||||
|
#define EIGEN_INCLUDE_TYPE_TRAITS
|
||||||
|
#else
|
||||||
|
#define EIGEN_HAS_TYPE_TRAITS 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Does the compiler support variadic templates?
|
// Does the compiler support variadic templates?
|
||||||
#ifndef EIGEN_HAS_VARIADIC_TEMPLATES
|
#ifndef EIGEN_HAS_VARIADIC_TEMPLATES
|
||||||
#if EIGEN_MAX_CPP_VER>=11 && (__cplusplus > 199711L || EIGEN_COMP_MSVC >= 1900) \
|
#if EIGEN_MAX_CPP_VER>=11 && (__cplusplus > 199711L || EIGEN_COMP_MSVC >= 1900) \
|
||||||
|
@ -34,6 +34,20 @@ inline IndexDest convert_index(const IndexSrc& idx) {
|
|||||||
return IndexDest(idx);
|
return IndexDest(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// true if T can be considered as an integral index (i.e., and integral type or enum)
|
||||||
|
template<typename T> struct is_valid_index_type
|
||||||
|
{
|
||||||
|
enum { value =
|
||||||
|
#if EIGEN_HAS_TYPE_TRAITS
|
||||||
|
internal::is_integral<T>::value || std::is_enum<T>::value
|
||||||
|
#elif EIGEN_COMP_MSVC
|
||||||
|
internal::is_integral<T>::value || __is_enum(T)
|
||||||
|
#else
|
||||||
|
// without C++11, we use is_convertible to Index instead of is_integral in order to treat enums as Index.
|
||||||
|
internal::is_convertible<T,Index>::value
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// promote_scalar_arg is an helper used in operation between an expression and a scalar, like:
|
// promote_scalar_arg is an helper used in operation between an expression and a scalar, like:
|
||||||
// expression * scalar
|
// expression * scalar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user