mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Initial fixes for bug #85.
Renamed meta_{true|false} to {true|false}_type, meta_if to conditional, is_same_type to is_same, un{ref|pointer|const} to remove_{reference|pointer|const} and makeconst to add_const.
Changed boolean type 'ret' member to 'value'.
Changed 'ret' members refering to types to 'type'.
Adapted all code occurences.
This commit is contained in:
@@ -173,10 +173,10 @@ template<typename XprType> struct blas_traits
|
||||
int(inner_stride_at_compile_time<XprType>::ret) == 1)
|
||||
) ? 1 : 0
|
||||
};
|
||||
typedef typename meta_if<bool(HasUsableDirectAccess),
|
||||
typedef typename conditional<bool(HasUsableDirectAccess),
|
||||
ExtractType,
|
||||
typename _ExtractType::PlainObject
|
||||
>::ret DirectLinearAccessType;
|
||||
>::type DirectLinearAccessType;
|
||||
static inline ExtractType extract(const XprType& x) { return x; }
|
||||
static inline Scalar extractScalarFactor(const XprType&) { return Scalar(1); }
|
||||
};
|
||||
@@ -234,10 +234,10 @@ struct blas_traits<Transpose<NestedXpr> >
|
||||
typedef Transpose<NestedXpr> XprType;
|
||||
typedef Transpose<typename Base::_ExtractType> ExtractType;
|
||||
typedef Transpose<typename Base::_ExtractType> _ExtractType;
|
||||
typedef typename meta_if<bool(Base::HasUsableDirectAccess),
|
||||
typedef typename conditional<bool(Base::HasUsableDirectAccess),
|
||||
ExtractType,
|
||||
typename ExtractType::PlainObject
|
||||
>::ret DirectLinearAccessType;
|
||||
>::type DirectLinearAccessType;
|
||||
enum {
|
||||
IsTransposed = Base::IsTransposed ? 0 : 1
|
||||
};
|
||||
|
||||
@@ -35,29 +35,29 @@ namespace internal {
|
||||
* we however don't want to add a dependency to Boost.
|
||||
*/
|
||||
|
||||
struct meta_true { enum { ret = 1 }; };
|
||||
struct meta_false { enum { ret = 0 }; };
|
||||
struct true_type { enum { value = 1 }; };
|
||||
struct false_type { enum { value = 0 }; };
|
||||
|
||||
template<bool Condition, typename Then, typename Else>
|
||||
struct meta_if { typedef Then ret; };
|
||||
struct conditional { typedef Then type; };
|
||||
|
||||
template<typename Then, typename Else>
|
||||
struct meta_if <false, Then, Else> { typedef Else ret; };
|
||||
struct conditional <false, Then, Else> { typedef Else type; };
|
||||
|
||||
template<typename T, typename U> struct is_same_type { enum { ret = 0 }; };
|
||||
template<typename T> struct is_same_type<T,T> { enum { ret = 1 }; };
|
||||
template<typename T, typename U> struct is_same { enum { value = 0 }; };
|
||||
template<typename T> struct is_same<T,T> { enum { value = 1 }; };
|
||||
|
||||
template<typename T> struct unref { typedef T type; };
|
||||
template<typename T> struct unref<T&> { typedef T type; };
|
||||
template<typename T> struct remove_reference { typedef T type; };
|
||||
template<typename T> struct remove_reference<T&> { typedef T type; };
|
||||
|
||||
template<typename T> struct unpointer { typedef T type; };
|
||||
template<typename T> struct unpointer<T*> { typedef T type; };
|
||||
template<typename T> struct unpointer<T*const> { 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<typename T> struct unconst { typedef T type; };
|
||||
template<typename T> struct unconst<const T> { typedef T type; };
|
||||
template<typename T> struct unconst<T const &> { typedef T & type; };
|
||||
template<typename T> struct unconst<T const *> { typedef T * type; };
|
||||
template<typename T> struct remove_const { typedef T type; };
|
||||
template<typename T> struct remove_const<const T> { typedef T type; };
|
||||
template<typename T> struct remove_const<T const &> { typedef T & type; };
|
||||
template<typename T> struct remove_const<T const *> { typedef T * type; };
|
||||
|
||||
template<typename T> struct cleantype { typedef T type; };
|
||||
template<typename T> struct cleantype<const T> { typedef typename cleantype<T>::type type; };
|
||||
@@ -66,33 +66,33 @@ template<typename T> struct cleantype<T&> { typedef typename cleantype<T>
|
||||
template<typename T> struct cleantype<const T*> { typedef typename cleantype<T>::type type; };
|
||||
template<typename T> struct cleantype<T*> { typedef typename cleantype<T>::type type; };
|
||||
|
||||
template<typename T> struct is_arithmetic { enum { ret = false }; };
|
||||
template<> struct is_arithmetic<float> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<double> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<long double> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<bool> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<char> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<signed char> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<unsigned char> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<signed short> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<unsigned short>{ enum { ret = true }; };
|
||||
template<> struct is_arithmetic<signed int> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<unsigned int> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<signed long> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<unsigned long> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<signed long long> { enum { ret = true }; };
|
||||
template<> struct is_arithmetic<unsigned long long> { enum { ret = true }; };
|
||||
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 }; };
|
||||
template<> struct is_arithmetic<long double> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<bool> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<char> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed char> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned char> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed short> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned short>{ enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed int> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned int> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed long> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned long> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<signed long long> { enum { value = true }; };
|
||||
template<> struct is_arithmetic<unsigned long long> { enum { value = true }; };
|
||||
|
||||
template<typename T> struct makeconst { typedef const T type; };
|
||||
template<typename T> struct makeconst<const T> { typedef const T type; };
|
||||
template<typename T> struct makeconst<T&> { typedef const T& type; };
|
||||
template<typename T> struct makeconst<const T&> { typedef const T& type; };
|
||||
template<typename T> struct makeconst<T*> { typedef const T* type; };
|
||||
template<typename T> struct makeconst<const T*> { typedef const T* type; };
|
||||
template<typename T> struct add_const { typedef const T type; };
|
||||
template<typename T> struct add_const<const T> { typedef const T type; };
|
||||
template<typename T> struct add_const<T&> { typedef const T& type; };
|
||||
template<typename T> struct add_const<const T&> { typedef const T& type; };
|
||||
template<typename T> struct add_const<T*> { typedef const T* type; };
|
||||
template<typename T> struct add_const<const T*> { typedef const T* type; };
|
||||
|
||||
template<typename T> struct makeconst_return_type
|
||||
{
|
||||
typedef typename meta_if<is_arithmetic<T>::ret, T, typename makeconst<T>::type>::ret type;
|
||||
typedef typename conditional<is_arithmetic<T>::value, T, typename add_const<T>::type>::type type;
|
||||
};
|
||||
|
||||
/** \internal Allows to enable/disable an overload
|
||||
|
||||
@@ -52,7 +52,7 @@ class no_assignment_operator
|
||||
template<typename I1, typename I2>
|
||||
struct promote_index_type
|
||||
{
|
||||
typedef typename meta_if<(sizeof(I1)<sizeof(I2)), I2, I1>::ret type;
|
||||
typedef typename conditional<(sizeof(I1)<sizeof(I2)), I2, I1>::type type;
|
||||
};
|
||||
|
||||
/** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that
|
||||
@@ -281,11 +281,11 @@ struct is_reference<T&>
|
||||
template <typename T>
|
||||
struct ref_selector
|
||||
{
|
||||
typedef typename meta_if<
|
||||
typedef typename conditional<
|
||||
bool(traits<T>::Flags & NestByRefBit),
|
||||
T const&,
|
||||
T
|
||||
>::ret type;
|
||||
>::type type;
|
||||
};
|
||||
|
||||
/** \internal Determines how a given expression should be nested into another one.
|
||||
@@ -319,12 +319,12 @@ template<typename T, int n=1, typename PlainObject = typename eval<T>::type> str
|
||||
CostNoEval = (N-1) * int(CoeffReadCost)
|
||||
};
|
||||
|
||||
typedef typename meta_if<
|
||||
typedef typename conditional<
|
||||
( int(traits<T>::Flags) & EvalBeforeNestingBit ) ||
|
||||
( int(CostEval) <= int(CostNoEval) ),
|
||||
PlainObject,
|
||||
typename ref_selector<T>::type
|
||||
>::ret type;
|
||||
>::type type;
|
||||
|
||||
/* this is what the above logic should be updated to look like:
|
||||
enum {
|
||||
@@ -334,14 +334,14 @@ template<typename T, int n=1, typename PlainObject = typename eval<T>::type> str
|
||||
CostNoEval = n == Dynamic || (CoeffReadCost == Dynamic && n>1) ? int(Dynamic) : (n-1) * int(CoeffReadCost)
|
||||
};
|
||||
|
||||
typedef typename meta_if<
|
||||
typedef typename conditional<
|
||||
( int(traits<T>::Flags) & EvalBeforeNestingBit ) ||
|
||||
( int(CostNoEval) == Dynamic ? true
|
||||
: int(CostEval) == Dynamic ? false
|
||||
: int(CostEval) <= int(CostNoEval) ),
|
||||
PlainObject,
|
||||
typename ref_selector<T>::type
|
||||
>::ret type;
|
||||
>::type type;
|
||||
*/
|
||||
};
|
||||
|
||||
@@ -371,7 +371,7 @@ struct dense_xpr_base<Derived, ArrayXpr>
|
||||
/** \internal Helper base class to add a scalar multiple operator
|
||||
* overloads for complex types */
|
||||
template<typename Derived,typename Scalar,typename OtherScalar,
|
||||
bool EnableIt = !is_same_type<Scalar,OtherScalar>::ret >
|
||||
bool EnableIt = !is_same<Scalar,OtherScalar>::value >
|
||||
struct special_scalar_op_base : public DenseCoeffsBase<Derived>
|
||||
{
|
||||
// dummy operator* so that the
|
||||
@@ -412,8 +412,8 @@ template<typename XprType, typename CastType> struct cast_return_type
|
||||
typedef typename XprType::Scalar CurrentScalarType;
|
||||
typedef typename cleantype<CastType>::type _CastType;
|
||||
typedef typename _CastType::Scalar NewScalarType;
|
||||
typedef typename meta_if<is_same_type<CurrentScalarType,NewScalarType>::ret,
|
||||
const XprType&,CastType>::ret type;
|
||||
typedef typename conditional<is_same<CurrentScalarType,NewScalarType>::value,
|
||||
const XprType&,CastType>::type type;
|
||||
};
|
||||
|
||||
template <typename A, typename B> struct promote_storage_type;
|
||||
@@ -434,11 +434,11 @@ struct plain_row_type
|
||||
typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime,
|
||||
ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType;
|
||||
|
||||
typedef typename meta_if<
|
||||
is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret,
|
||||
typedef typename conditional<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixRowType,
|
||||
ArrayRowType
|
||||
>::ret type;
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>
|
||||
@@ -449,11 +449,11 @@ struct plain_col_type
|
||||
typedef Array<Scalar, ExpressionType::RowsAtCompileTime, 1,
|
||||
ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> ArrayColType;
|
||||
|
||||
typedef typename meta_if<
|
||||
is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret,
|
||||
typedef typename conditional<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixColType,
|
||||
ArrayColType
|
||||
>::ret type;
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>
|
||||
@@ -465,11 +465,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 meta_if<
|
||||
is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret,
|
||||
typedef typename conditional<
|
||||
is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,
|
||||
MatrixDiagType,
|
||||
ArrayDiagType
|
||||
>::ret type;
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
Reference in New Issue
Block a user