mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Replace Eigen type metaprogramming with corresponding std types and make use of alias templates
This commit is contained in:
committed by
Antonio Sánchez
parent
514f90c9ff
commit
421cbf0866
@@ -428,10 +428,10 @@ template<typename XprType> struct blas_traits
|
||||
) ? 1 : 0,
|
||||
HasScalarFactor = false
|
||||
};
|
||||
typedef typename conditional<bool(HasUsableDirectAccess),
|
||||
typedef std::conditional_t<bool(HasUsableDirectAccess),
|
||||
ExtractType,
|
||||
typename ExtractType_::PlainObject
|
||||
>::type DirectLinearAccessType;
|
||||
> DirectLinearAccessType;
|
||||
static inline EIGEN_DEVICE_FUNC ExtractType extract(const XprType& x) { return x; }
|
||||
static inline EIGEN_DEVICE_FUNC const Scalar extractScalarFactor(const XprType&) { return Scalar(1); }
|
||||
};
|
||||
@@ -514,10 +514,10 @@ struct blas_traits<Transpose<NestedXpr> >
|
||||
typedef Transpose<NestedXpr> XprType;
|
||||
typedef Transpose<const typename Base::ExtractType_> ExtractType; // const to get rid of a compile error; anyway blas traits are only used on the RHS
|
||||
typedef Transpose<const typename Base::ExtractType_> ExtractType_;
|
||||
typedef typename conditional<bool(Base::HasUsableDirectAccess),
|
||||
typedef std::conditional_t<bool(Base::HasUsableDirectAccess),
|
||||
ExtractType,
|
||||
typename ExtractType::PlainObject
|
||||
>::type DirectLinearAccessType;
|
||||
> DirectLinearAccessType;
|
||||
enum {
|
||||
IsTransposed = Base::IsTransposed ? 0 : 1
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ template<int Value = Dynamic> class OuterStride;
|
||||
template<typename MatrixType, int MapOptions=Unaligned, typename StrideType = Stride<0,0> > class Map;
|
||||
template<typename Derived> class RefBase;
|
||||
template<typename PlainObjectType, int Options = 0,
|
||||
typename StrideType = typename internal::conditional<PlainObjectType::IsVectorAtCompileTime,InnerStride<1>,OuterStride<> >::type > class Ref;
|
||||
typename StrideType = typename std::conditional_t<PlainObjectType::IsVectorAtCompileTime,InnerStride<1>,OuterStride<> > > class Ref;
|
||||
template<typename ViewOp, typename MatrixType, typename StrideType = Stride<0,0>> class CwiseUnaryView;
|
||||
|
||||
template<typename Derived> class TriangularBase;
|
||||
|
||||
@@ -99,7 +99,7 @@ template<> struct get_compile_time_incr<SingleRange> {
|
||||
|
||||
// Turn a single index into something that looks like an array (i.e., that exposes a .size(), and operator[](int) methods)
|
||||
template<typename T, int XprSize>
|
||||
struct IndexedViewCompatibleType<T,XprSize,typename internal::enable_if<internal::is_integral<T>::value>::type> {
|
||||
struct IndexedViewCompatibleType<T,XprSize,std::enable_if_t<internal::is_integral<T>::value>> {
|
||||
// Here we could simply use Array, but maybe it's less work for the compiler to use
|
||||
// a simpler wrapper as SingleRange
|
||||
//typedef Eigen::Array<Index,1,1> type;
|
||||
@@ -107,13 +107,13 @@ struct IndexedViewCompatibleType<T,XprSize,typename internal::enable_if<internal
|
||||
};
|
||||
|
||||
template<typename T, int XprSize>
|
||||
struct IndexedViewCompatibleType<T, XprSize, typename enable_if<symbolic::is_symbolic<T>::value>::type> {
|
||||
struct IndexedViewCompatibleType<T, XprSize, std::enable_if_t<symbolic::is_symbolic<T>::value>> {
|
||||
typedef SingleRange type;
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
typename enable_if<symbolic::is_symbolic<T>::value,SingleRange>::type
|
||||
std::enable_if_t<symbolic::is_symbolic<T>::value,SingleRange>
|
||||
makeIndexedViewCompatible(const T& id, Index size, SpecializedType) {
|
||||
return eval_expr_given_size(id,size);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ template<typename T> EIGEN_DEVICE_FUNC Index get_runtime_value(const T &x) { ret
|
||||
template<typename T, int DynamicKey=Dynamic, typename EnableIf=void> struct cleanup_index_type { typedef T type; };
|
||||
|
||||
// Convert any integral type (e.g., short, int, unsigned int, etc.) to Eigen::Index
|
||||
template<typename T, int DynamicKey> struct cleanup_index_type<T,DynamicKey,typename internal::enable_if<internal::is_integral<T>::value>::type> { typedef Index type; };
|
||||
template<typename T, int DynamicKey> struct cleanup_index_type<T,DynamicKey,std::enable_if_t<internal::is_integral<T>::value>> { typedef Index type; };
|
||||
|
||||
// If VariableAndFixedInt does not match DynamicKey, then we turn it to a pure compile-time value:
|
||||
template<int N, int DynamicKey> struct cleanup_index_type<VariableAndFixedInt<N>, DynamicKey> { typedef FixedInt<N> type; };
|
||||
|
||||
@@ -90,24 +90,6 @@ struct bool_constant<true> : true_type {};
|
||||
template<>
|
||||
struct bool_constant<false> : false_type {};
|
||||
|
||||
template<bool Condition, typename Then, typename Else>
|
||||
struct conditional { typedef Then type; };
|
||||
|
||||
template<typename Then, typename Else>
|
||||
struct conditional <false, Then, Else> { typedef Else type; };
|
||||
|
||||
template<typename T> struct remove_reference { typedef T type; };
|
||||
template<typename T> struct remove_reference<T&> { typedef T type; };
|
||||
|
||||
template<typename T> struct remove_pointer { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T*> { typedef T type; };
|
||||
template<typename T> struct remove_pointer<T*const> { typedef T type; };
|
||||
|
||||
template <class T> struct remove_const { typedef T type; };
|
||||
template <class T> struct remove_const<const T> { typedef T type; };
|
||||
template <class T> struct remove_const<const T[]> { typedef T type[]; };
|
||||
template <class T, unsigned int Size> struct remove_const<const T[Size]> { typedef T type[Size]; };
|
||||
|
||||
template<typename T> struct remove_all { typedef T type; };
|
||||
template<typename T> struct remove_all<const T> { typedef typename remove_all<T>::type type; };
|
||||
template<typename T> struct remove_all<T const&> { typedef typename remove_all<T>::type type; };
|
||||
@@ -115,6 +97,9 @@ template<typename T> struct remove_all<T&> { typedef typename remove_all<
|
||||
template<typename T> struct remove_all<T const*> { typedef typename remove_all<T>::type type; };
|
||||
template<typename T> struct remove_all<T*> { typedef typename remove_all<T>::type type; };
|
||||
|
||||
template<typename T>
|
||||
using remove_all_t = typename remove_all<T>::type;
|
||||
|
||||
template<typename T> struct is_arithmetic { enum { value = false }; };
|
||||
template<> struct is_arithmetic<float> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<double> { enum { value = true }; };
|
||||
@@ -134,7 +119,7 @@ template<typename T, typename U> struct is_same { enum { value = 0 }; };
|
||||
template<typename T> struct is_same<T,T> { enum { value = 1 }; };
|
||||
|
||||
template< class T >
|
||||
struct is_void : is_same<void, typename remove_const<T>::type> {};
|
||||
struct is_void : is_same<void, std::remove_const_t<T>> {};
|
||||
|
||||
template<> struct is_arithmetic<signed long long> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned long long> { enum { value = true }; };
|
||||
@@ -142,9 +127,6 @@ using std::is_integral;
|
||||
|
||||
using std::make_unsigned;
|
||||
|
||||
template <typename T> struct add_const { typedef const T type; };
|
||||
template <typename T> struct add_const<T&> { typedef T& type; };
|
||||
|
||||
template <typename T> struct is_const { enum { value = 0 }; };
|
||||
template <typename T> struct is_const<T const> { enum { value = 1 }; };
|
||||
|
||||
@@ -154,16 +136,11 @@ template<typename T> struct add_const_on_value_type<T*> { typedef T const
|
||||
template<typename T> struct add_const_on_value_type<T* const> { typedef T const* const type; };
|
||||
template<typename T> struct add_const_on_value_type<T const* const> { typedef T const* const type; };
|
||||
|
||||
template<typename T>
|
||||
using add_const_on_value_type_t = typename add_const_on_value_type<T>::type;
|
||||
|
||||
using std::is_convertible;
|
||||
|
||||
/** \internal Allows to enable/disable an overload
|
||||
* according to a compile time condition.
|
||||
*/
|
||||
template<bool Condition, typename T=void> struct enable_if;
|
||||
|
||||
template<typename T> struct enable_if<true,T>
|
||||
{ typedef T type; };
|
||||
|
||||
/** \internal
|
||||
* A base class do disable default copy ctor and copy assignment operator.
|
||||
*/
|
||||
@@ -194,7 +171,7 @@ template<typename T, typename EnableIf = void> struct array_size {
|
||||
enum { value = Dynamic };
|
||||
};
|
||||
|
||||
template<typename T> struct array_size<T,typename internal::enable_if<((T::SizeAtCompileTime&0)==0)>::type> {
|
||||
template<typename T> struct array_size<T, std::enable_if_t<((T::SizeAtCompileTime&0)==0)>> {
|
||||
enum { value = T::SizeAtCompileTime };
|
||||
};
|
||||
|
||||
@@ -256,24 +233,24 @@ template<typename T> struct result_of;
|
||||
template<typename F, typename... ArgTypes>
|
||||
struct result_of<F(ArgTypes...)> {
|
||||
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
||||
typedef typename remove_all<type1>::type type;
|
||||
typedef remove_all_t<type1> type;
|
||||
};
|
||||
|
||||
template<typename F, typename... ArgTypes>
|
||||
struct invoke_result {
|
||||
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
||||
typedef typename remove_all<type1>::type type;
|
||||
typedef remove_all_t<type1> type;
|
||||
};
|
||||
#else
|
||||
template<typename T> struct result_of {
|
||||
typedef typename std::result_of<T>::type type1;
|
||||
typedef typename remove_all<type1>::type type;
|
||||
typedef remove_all_t<type1> type;
|
||||
};
|
||||
|
||||
template<typename F, typename... ArgTypes>
|
||||
struct invoke_result {
|
||||
typedef typename result_of<F(ArgTypes...)>::type type1;
|
||||
typedef typename remove_all<type1>::type type;
|
||||
typedef remove_all_t<type1> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -305,7 +282,7 @@ template<typename T> const T* return_ptr();
|
||||
template <typename T, typename IndexType=Index>
|
||||
struct has_nullary_operator
|
||||
{
|
||||
template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()())>0)>::type * = 0);
|
||||
template <typename C> static meta_yes testFunctor(C const *,std::enable_if_t<(sizeof(return_ptr<C>()->operator()())>0)> * = 0);
|
||||
static meta_no testFunctor(...);
|
||||
|
||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||
@@ -314,7 +291,7 @@ struct has_nullary_operator
|
||||
template <typename T, typename IndexType=Index>
|
||||
struct has_unary_operator
|
||||
{
|
||||
template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()(IndexType(0)))>0)>::type * = 0);
|
||||
template <typename C> static meta_yes testFunctor(C const *,std::enable_if_t<(sizeof(return_ptr<C>()->operator()(IndexType(0)))>0)> * = 0);
|
||||
static meta_no testFunctor(...);
|
||||
|
||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||
@@ -323,7 +300,7 @@ struct has_unary_operator
|
||||
template <typename T, typename IndexType=Index>
|
||||
struct has_binary_operator
|
||||
{
|
||||
template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()(IndexType(0),IndexType(0)))>0)>::type * = 0);
|
||||
template <typename C> static meta_yes testFunctor(C const *,std::enable_if_t<(sizeof(return_ptr<C>()->operator()(IndexType(0),IndexType(0)))>0)> * = 0);
|
||||
static meta_no testFunctor(...);
|
||||
|
||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||
@@ -381,7 +358,7 @@ template<typename T, typename U> struct scalar_product_traits
|
||||
// FIXME quick workaround around current limitation of result_of
|
||||
// template<typename Scalar, typename ArgType0, typename ArgType1>
|
||||
// struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> {
|
||||
// typedef typename scalar_product_traits<typename remove_all<ArgType0>::type, typename remove_all<ArgType1>::type>::ReturnType type;
|
||||
// typedef typename scalar_product_traits<remove_all_t<ArgType0>, remove_all_t<ArgType1>>::ReturnType type;
|
||||
// };
|
||||
|
||||
/** \internal Obtains a POD type suitable to use as storage for an object of a size
|
||||
|
||||
@@ -28,9 +28,9 @@ class Serializer;
|
||||
|
||||
// Specialization for POD types.
|
||||
template<typename T>
|
||||
class Serializer<T, typename std::enable_if<
|
||||
class Serializer<T, typename std::enable_if_t<
|
||||
std::is_trivial<T>::value
|
||||
&& std::is_standard_layout<T>::value>::type > {
|
||||
&& std::is_standard_layout<T>::value>> {
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,7 +113,7 @@ class no_assignment_operator
|
||||
template<typename I1, typename I2>
|
||||
struct promote_index_type
|
||||
{
|
||||
typedef typename conditional<(sizeof(I1)<sizeof(I2)), I2, I1>::type type;
|
||||
typedef std::conditional_t<(sizeof(I1)<sizeof(I2)), I2, I1> type;
|
||||
};
|
||||
|
||||
/** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that
|
||||
@@ -409,28 +409,28 @@ template<typename T> struct plain_matrix_type_row_major
|
||||
template <typename T>
|
||||
struct ref_selector
|
||||
{
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
bool(traits<T>::Flags & NestByRefBit),
|
||||
T const&,
|
||||
const T
|
||||
>::type type;
|
||||
> type;
|
||||
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
bool(traits<T>::Flags & NestByRefBit),
|
||||
T &,
|
||||
T
|
||||
>::type non_const_type;
|
||||
> non_const_type;
|
||||
};
|
||||
|
||||
/** \internal Adds the const qualifier on the value-type of T2 if and only if T1 is a const type */
|
||||
template<typename T1, typename T2>
|
||||
struct transfer_constness
|
||||
{
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
bool(internal::is_const<T1>::value),
|
||||
typename internal::add_const_on_value_type<T2>::type,
|
||||
add_const_on_value_type_t<T2>,
|
||||
T2
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ template<typename T, int n, typename PlainObject = typename plain_object_eval<T>
|
||||
Evaluate = (int(evaluator<T>::Flags) & EvalBeforeNestingBit) || (int(CostEval) < int(CostNoEval))
|
||||
};
|
||||
|
||||
typedef typename conditional<Evaluate, PlainObject, typename ref_selector<T>::type>::type type;
|
||||
typedef std::conditional_t<Evaluate, PlainObject, typename ref_selector<T>::type> type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -503,10 +503,10 @@ struct generic_xpr_base<Derived, XprKind, Dense>
|
||||
template<typename XprType, typename CastType> struct cast_return_type
|
||||
{
|
||||
typedef typename XprType::Scalar CurrentScalarType;
|
||||
typedef typename remove_all<CastType>::type CastType_;
|
||||
typedef remove_all_t<CastType> CastType_;
|
||||
typedef typename CastType_::Scalar NewScalarType;
|
||||
typedef typename conditional<is_same<CurrentScalarType,NewScalarType>::value,
|
||||
const XprType&,CastType>::type type;
|
||||
typedef std::conditional_t<is_same<CurrentScalarType,NewScalarType>::value,
|
||||
const XprType&,CastType> type;
|
||||
};
|
||||
|
||||
template <typename A, typename B> struct promote_storage_type;
|
||||
@@ -597,11 +597,11 @@ struct plain_row_type
|
||||
typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime,
|
||||
int(ExpressionType::PlainObject::Options) | int(RowMajor), 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType;
|
||||
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixRowType,
|
||||
ArrayRowType
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>
|
||||
@@ -612,11 +612,11 @@ struct plain_col_type
|
||||
typedef Array<Scalar, ExpressionType::RowsAtCompileTime, 1,
|
||||
ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> ArrayColType;
|
||||
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixColType,
|
||||
ArrayColType
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>
|
||||
@@ -629,11 +629,11 @@ struct plain_diag_type
|
||||
typedef Matrix<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> MatrixDiagType;
|
||||
typedef Array<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> ArrayDiagType;
|
||||
|
||||
typedef typename conditional<
|
||||
typedef std::conditional_t<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixDiagType,
|
||||
ArrayDiagType
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
template<typename Expr,typename Scalar = typename Expr::Scalar>
|
||||
@@ -647,7 +647,7 @@ struct plain_constant_type
|
||||
typedef Matrix<Scalar, traits<Expr>::RowsAtCompileTime, traits<Expr>::ColsAtCompileTime,
|
||||
Options, traits<Expr>::MaxRowsAtCompileTime,traits<Expr>::MaxColsAtCompileTime> matrix_type;
|
||||
|
||||
typedef CwiseNullaryOp<scalar_constant_op<Scalar>, const typename conditional<is_same< typename traits<Expr>::XprKind, MatrixXpr >::value, matrix_type, array_type>::type > type;
|
||||
typedef CwiseNullaryOp<scalar_constant_op<Scalar>, const std::conditional_t<is_same< typename traits<Expr>::XprKind, MatrixXpr >::value, matrix_type, array_type> > type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType>
|
||||
@@ -687,14 +687,14 @@ struct possibly_same_dense {
|
||||
|
||||
template<typename T1, typename T2>
|
||||
EIGEN_DEVICE_FUNC
|
||||
bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if<possibly_same_dense<T1,T2>::value>::type * = 0)
|
||||
bool is_same_dense(const T1 &mat1, const T2 &mat2, std::enable_if_t<possibly_same_dense<T1,T2>::value> * = 0)
|
||||
{
|
||||
return (mat1.data()==mat2.data()) && (mat1.innerStride()==mat2.innerStride()) && (mat1.outerStride()==mat2.outerStride());
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
EIGEN_DEVICE_FUNC
|
||||
bool is_same_dense(const T1 &, const T2 &, typename enable_if<!possibly_same_dense<T1,T2>::value>::type * = 0)
|
||||
bool is_same_dense(const T1 &, const T2 &, std::enable_if_t<!possibly_same_dense<T1,T2>::value> * = 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -716,9 +716,9 @@ struct scalar_div_cost<std::complex<T>, Vectorized> {
|
||||
|
||||
|
||||
template<bool Vectorized>
|
||||
struct scalar_div_cost<signed long,Vectorized,typename conditional<sizeof(long)==8,void,false_type>::type> { enum { value = 24 }; };
|
||||
struct scalar_div_cost<signed long,Vectorized, std::conditional_t<sizeof(long)==8,void,false_type>> { enum { value = 24 }; };
|
||||
template<bool Vectorized>
|
||||
struct scalar_div_cost<unsigned long,Vectorized,typename conditional<sizeof(long)==8,void,false_type>::type> { enum { value = 21 }; };
|
||||
struct scalar_div_cost<unsigned long,Vectorized, std::conditional_t<sizeof(long)==8,void,false_type>> { enum { value = 21 }; };
|
||||
|
||||
|
||||
#ifdef EIGEN_DEBUG_ASSIGN
|
||||
@@ -807,12 +807,12 @@ struct ScalarBinaryOpTraits<T,T,BinaryOp>
|
||||
};
|
||||
|
||||
template <typename T, typename BinaryOp>
|
||||
struct ScalarBinaryOpTraits<T, typename NumTraits<typename internal::enable_if<NumTraits<T>::IsComplex,T>::type>::Real, BinaryOp>
|
||||
struct ScalarBinaryOpTraits<T, typename NumTraits<std::enable_if_t<NumTraits<T>::IsComplex,T>>::Real, BinaryOp>
|
||||
{
|
||||
typedef T ReturnType;
|
||||
};
|
||||
template <typename T, typename BinaryOp>
|
||||
struct ScalarBinaryOpTraits<typename NumTraits<typename internal::enable_if<NumTraits<T>::IsComplex,T>::type>::Real, T, BinaryOp>
|
||||
struct ScalarBinaryOpTraits<typename NumTraits<std::enable_if_t<NumTraits<T>::IsComplex,T>>::Real, T, BinaryOp>
|
||||
{
|
||||
typedef T ReturnType;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user