diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index df3d72498..9ae6d69ce 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -96,7 +96,7 @@ struct promote_scalar_arg; template struct promote_scalar_arg { - typedef T type; + using type = T; }; // Recursively check safe conversion to PromotedType, and then ExprScalar if they are different. @@ -112,7 +112,7 @@ struct promote_scalar_arg : promote_scalar_arg_unsupported struct promote_scalar_arg_unsupported { - typedef PromotedType type; + using type = PromotedType; }; // No match, but no real-to-integer issues, and ExprScalar and current PromotedType are different, @@ -131,8 +131,7 @@ struct promote_scalar_arg_unsupported {}; // classes inheriting no_assignment_operator don't generate a default operator=. class no_assignment_operator { - private: - no_assignment_operator& operator=(const no_assignment_operator&); + no_assignment_operator& operator=(const no_assignment_operator&) = delete; protected: EIGEN_DEFAULT_COPY_CONSTRUCTOR(no_assignment_operator) @@ -142,7 +141,7 @@ class no_assignment_operator { /** \internal return the index type with the largest number of bits */ template struct promote_index_type { - typedef std::conditional_t<(sizeof(I1) < sizeof(I2)), I2, I1> type; + using type = std::conditional_t<(sizeof(I1) < sizeof(I2)), I2, I1>; }; /** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that @@ -275,17 +274,17 @@ struct find_best_packet_helper; template struct find_best_packet_helper { - typedef PacketType type; + using type = PacketType; }; template struct find_best_packet_helper { - typedef typename find_best_packet_helper::half>::type type; + using type = typename find_best_packet_helper::half>::type; }; template struct find_best_packet { - typedef typename find_best_packet_helper::type>::type type; + using type = typename find_best_packet_helper::type>::type; }; template -class make_proper_matrix_type { - enum { - IsColVector = Cols_ == 1 && Rows_ != 1, - IsRowVector = Rows_ == 1 && Cols_ != 1, - Options = IsColVector ? (Options_ | ColMajor) & ~RowMajor - : IsRowVector ? (Options_ | RowMajor) & ~ColMajor - : Options_ - }; +struct make_proper_matrix_type { + private: + static constexpr bool IsColVector = Cols_ == 1 && Rows_ != 1; + static constexpr bool IsRowVector = Rows_ == 1 && Cols_ != 1; + static constexpr int Options = IsColVector ? (Options_ | ColMajor) & ~RowMajor + : IsRowVector ? (Options_ | RowMajor) & ~ColMajor + : Options_; public: - typedef Matrix type; + using type = Matrix; }; constexpr unsigned compute_matrix_flags(int Options) { @@ -389,32 +387,30 @@ template struct plain_matrix_type_dense; template struct plain_matrix_type { - typedef typename plain_matrix_type_dense::XprKind, traits::Flags>::type type; + using type = typename plain_matrix_type_dense::XprKind, traits::Flags>::type; }; template struct plain_matrix_type { - typedef typename T::PlainObject type; + using type = typename T::PlainObject; }; template struct plain_matrix_type { - typedef typename T::PlainObject type; + using type = typename T::PlainObject; }; template struct plain_matrix_type_dense { - typedef Matrix::Scalar, traits::RowsAtCompileTime, traits::ColsAtCompileTime, - AutoAlign | (Flags & RowMajorBit ? RowMajor : ColMajor), traits::MaxRowsAtCompileTime, - traits::MaxColsAtCompileTime> - type; + using type = Matrix::Scalar, traits::RowsAtCompileTime, traits::ColsAtCompileTime, + AutoAlign | (Flags & RowMajorBit ? RowMajor : ColMajor), traits::MaxRowsAtCompileTime, + traits::MaxColsAtCompileTime>; }; template struct plain_matrix_type_dense { - typedef Array::Scalar, traits::RowsAtCompileTime, traits::ColsAtCompileTime, - AutoAlign | (Flags & RowMajorBit ? RowMajor : ColMajor), traits::MaxRowsAtCompileTime, - traits::MaxColsAtCompileTime> - type; + using type = Array::Scalar, traits::RowsAtCompileTime, traits::ColsAtCompileTime, + AutoAlign | (Flags & RowMajorBit ? RowMajor : ColMajor), traits::MaxRowsAtCompileTime, + traits::MaxColsAtCompileTime>; }; /* eval : the return type of eval(). For matrices, this is just a const reference @@ -426,36 +422,28 @@ struct eval; template struct eval { - typedef typename plain_matrix_type::type type; - // typedef typename T::PlainObject type; - // typedef T::Matrix::Scalar, - // traits::RowsAtCompileTime, - // traits::ColsAtCompileTime, - // AutoAlign | (traits::Flags&RowMajorBit ? RowMajor : ColMajor), - // traits::MaxRowsAtCompileTime, - // traits::MaxColsAtCompileTime - // > type; + using type = typename plain_matrix_type::type; }; template struct eval { - typedef typename plain_matrix_type::type type; + using type = typename plain_matrix_type::type; }; template struct eval { - typedef typename plain_matrix_type::type type; + using type = typename plain_matrix_type::type; }; // for matrices, no need to evaluate, just use a const reference to avoid a useless copy template struct eval, Dense> { - typedef const Matrix& type; + using type = const Matrix&; }; template struct eval, Dense> { - typedef const Array& type; + using type = const Array&; }; /* similar to plain_matrix_type, but using the evaluator's Flags */ @@ -464,37 +452,31 @@ struct plain_object_eval; template struct plain_object_eval { - typedef typename plain_matrix_type_dense::XprKind, evaluator::Flags>::type type; + using type = typename plain_matrix_type_dense::XprKind, evaluator::Flags>::type; }; /* plain_matrix_type_column_major : same as plain_matrix_type but guaranteed to be column-major */ template struct plain_matrix_type_column_major { - enum { - Rows = traits::RowsAtCompileTime, - Cols = traits::ColsAtCompileTime, - MaxRows = traits::MaxRowsAtCompileTime, - MaxCols = traits::MaxColsAtCompileTime - }; - typedef Matrix::Scalar, Rows, Cols, (MaxRows == 1 && MaxCols != 1) ? RowMajor : ColMajor, MaxRows, - MaxCols> - type; + static constexpr int Rows = traits::RowsAtCompileTime; + static constexpr int Cols = traits::ColsAtCompileTime; + static constexpr int MaxRows = traits::MaxRowsAtCompileTime; + static constexpr int MaxCols = traits::MaxColsAtCompileTime; + using type = Matrix::Scalar, Rows, Cols, (MaxRows == 1 && MaxCols != 1) ? RowMajor : ColMajor, + MaxRows, MaxCols>; }; /* plain_matrix_type_row_major : same as plain_matrix_type but guaranteed to be row-major */ template struct plain_matrix_type_row_major { - enum { - Rows = traits::RowsAtCompileTime, - Cols = traits::ColsAtCompileTime, - MaxRows = traits::MaxRowsAtCompileTime, - MaxCols = traits::MaxColsAtCompileTime - }; - typedef Matrix::Scalar, Rows, Cols, (MaxCols == 1 && MaxRows != 1) ? ColMajor : RowMajor, MaxRows, - MaxCols> - type; + static constexpr int Rows = traits::RowsAtCompileTime; + static constexpr int Cols = traits::ColsAtCompileTime; + static constexpr int MaxRows = traits::MaxRowsAtCompileTime; + static constexpr int MaxCols = traits::MaxColsAtCompileTime; + using type = Matrix::Scalar, Rows, Cols, (MaxCols == 1 && MaxRows != 1) ? ColMajor : RowMajor, + MaxRows, MaxCols>; }; /** \internal The reference selector for template expressions. The idea is that we don't @@ -502,15 +484,9 @@ struct plain_matrix_type_row_major { * objects which should generate no copying overhead. */ template struct ref_selector { - typedef std::conditional_t::Flags& NestByRefBit), T const&, const T> type; + using type = std::conditional_t::Flags& NestByRefBit), T const&, const T>; - typedef std::conditional_t::Flags& NestByRefBit), T&, T> non_const_type; -}; - -/** \internal Adds the const qualifier on the value-type of T2 if and only if T1 is a const type */ -template -struct transfer_constness { - typedef std::conditional_t::value), add_const_on_value_type_t, T2> type; + using non_const_type = std::conditional_t::Flags& NestByRefBit), T&, T>; }; // However, we still need a mechanism to detect whether an expression which is evaluated multiple time @@ -544,14 +520,9 @@ struct nested_eval { Evaluate = (int(evaluator::Flags) & EvalBeforeNestingBit) || (int(CostEval) < int(CostNoEval)) }; - typedef std::conditional_t::type> type; + using type = std::conditional_t::type>; }; -template -EIGEN_DEVICE_FUNC inline T* const_cast_ptr(const T* ptr) { - return const_cast(ptr); -} - template ::XprKind> struct dense_xpr_base { /* dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the @@ -560,12 +531,12 @@ struct dense_xpr_base { template struct dense_xpr_base { - typedef MatrixBase type; + using type = MatrixBase; }; template struct dense_xpr_base { - typedef ArrayBase type; + using type = ArrayBase; }; template ::XprKind, @@ -574,15 +545,15 @@ struct generic_xpr_base; template struct generic_xpr_base { - typedef typename dense_xpr_base::type type; + using type = typename dense_xpr_base::type; }; template struct cast_return_type { - typedef typename XprType::Scalar CurrentScalarType; - typedef remove_all_t CastType_; - typedef typename CastType_::Scalar NewScalarType; - typedef std::conditional_t::value, const XprType&, CastType> type; + using CurrentScalarType = typename XprType::Scalar; + using CastType_ = remove_all_t; + using NewScalarType = typename CastType_::Scalar; + using type = std::conditional_t::value, const XprType&, CastType>; }; template @@ -590,15 +561,15 @@ struct promote_storage_type; template struct promote_storage_type { - typedef A ret; + using ret = A; }; template struct promote_storage_type { - typedef A ret; + using ret = A; }; template struct promote_storage_type { - typedef A ret; + using ret = A; }; /** \internal Specify the "storage kind" of applying a coefficient-wise @@ -619,27 +590,27 @@ struct cwise_promote_storage_type; template struct cwise_promote_storage_type { - typedef A ret; + using ret = A; }; template struct cwise_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct cwise_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct cwise_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct cwise_promote_storage_type { - typedef Sparse ret; + using ret = Sparse; }; template struct cwise_promote_storage_type { - typedef Sparse ret; + using ret = Sparse; }; template @@ -679,74 +650,74 @@ struct product_promote_storage_type; template struct product_promote_storage_type { - typedef A ret; + using ret = A; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef A ret; + using ret = A; }; template struct product_promote_storage_type { - typedef B ret; + using ret = B; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef A ret; + using ret = A; }; template struct product_promote_storage_type { - typedef B ret; + using ret = B; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef A ret; + using ret = A; }; template struct product_promote_storage_type { - typedef B ret; + using ret = B; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; template struct product_promote_storage_type { - typedef Dense ret; + using ret = Dense; }; /** \internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type. @@ -754,63 +725,56 @@ struct product_promote_storage_type { */ template struct plain_row_type { - typedef Matrix - MatrixRowType; - typedef Array - ArrayRowType; + using MatrixRowType = + Matrix; + using ArrayRowType = + Array; - typedef std::conditional_t::XprKind, MatrixXpr>::value, MatrixRowType, - ArrayRowType> - type; + using type = std::conditional_t::XprKind, MatrixXpr>::value, MatrixRowType, + ArrayRowType>; }; template struct plain_col_type { - typedef Matrix - MatrixColType; - typedef Array - ArrayColType; + using MatrixColType = + Matrix; + using ArrayColType = Array; - typedef std::conditional_t::XprKind, MatrixXpr>::value, MatrixColType, - ArrayColType> - type; + using type = std::conditional_t::XprKind, MatrixXpr>::value, MatrixColType, + ArrayColType>; }; template struct plain_diag_type { - enum { - diag_size = internal::min_size_prefer_dynamic(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime), - max_diag_size = min_size_prefer_fixed(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime) - }; - typedef Matrix - MatrixDiagType; - typedef Array ArrayDiagType; + static constexpr int diag_size = + internal::min_size_prefer_dynamic(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime); + static constexpr int max_diag_size = + min_size_prefer_fixed(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime); + using MatrixDiagType = + Matrix; + using ArrayDiagType = Array; - typedef std::conditional_t::XprKind, MatrixXpr>::value, MatrixDiagType, - ArrayDiagType> - type; + using type = std::conditional_t::XprKind, MatrixXpr>::value, MatrixDiagType, + ArrayDiagType>; }; template struct plain_constant_type { - enum { Options = (traits::Flags & RowMajorBit) ? RowMajor : 0 }; + static constexpr int Options = (traits::Flags & RowMajorBit) ? RowMajor : 0; - typedef Array::RowsAtCompileTime, traits::ColsAtCompileTime, Options, - traits::MaxRowsAtCompileTime, traits::MaxColsAtCompileTime> - array_type; + using array_type = Array::RowsAtCompileTime, traits::ColsAtCompileTime, Options, + traits::MaxRowsAtCompileTime, traits::MaxColsAtCompileTime>; - typedef Matrix::RowsAtCompileTime, traits::ColsAtCompileTime, Options, - traits::MaxRowsAtCompileTime, traits::MaxColsAtCompileTime> - matrix_type; + using matrix_type = Matrix::RowsAtCompileTime, traits::ColsAtCompileTime, Options, + traits::MaxRowsAtCompileTime, traits::MaxColsAtCompileTime>; - typedef CwiseNullaryOp< + using type = CwiseNullaryOp< scalar_constant_op, - const std::conditional_t::XprKind, MatrixXpr>::value, matrix_type, array_type>> - type; + const std::conditional_t::XprKind, MatrixXpr>::value, matrix_type, array_type>>; }; template @@ -852,7 +816,7 @@ template struct glue_shapes; template <> struct glue_shapes { - typedef TriangularShape type; + using type = TriangularShape; }; template @@ -1047,34 +1011,34 @@ struct ScalarBinaryOpTraits template struct ScalarBinaryOpTraits { - typedef T ReturnType; + using ReturnType = T; }; template struct ScalarBinaryOpTraits::IsComplex, T>>::Real, BinaryOp> { - typedef T ReturnType; + using ReturnType = T; }; template struct ScalarBinaryOpTraits::IsComplex, T>>::Real, T, BinaryOp> { - typedef T ReturnType; + using ReturnType = T; }; // For Matrix * Permutation template struct ScalarBinaryOpTraits { - typedef T ReturnType; + using ReturnType = T; }; // For Permutation * Matrix template struct ScalarBinaryOpTraits { - typedef T ReturnType; + using ReturnType = T; }; // for Permutation*Permutation template struct ScalarBinaryOpTraits { - typedef void ReturnType; + using ReturnType = void; }; // We require Lhs and Rhs to have "compatible" scalar types.