mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-16 22:59:39 +08:00
bug #1692: enable enum as sizes of Matrix and Array
This commit is contained in:
parent
1936aac43f
commit
cf7e2e277f
@ -802,8 +802,10 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT(bool(NumTraits<T0>::IsInteger) &&
|
||||
bool(NumTraits<T1>::IsInteger),
|
||||
const bool t0_is_integer_alike = internal::is_valid_index_type<T0>::value;
|
||||
const bool t1_is_integer_alike = internal::is_valid_index_type<T1>::value;
|
||||
EIGEN_STATIC_ASSERT(t0_is_integer_alike &&
|
||||
t1_is_integer_alike,
|
||||
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
|
||||
resize(rows,cols);
|
||||
}
|
||||
@ -838,9 +840,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
&& ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>::type* = 0)
|
||||
{
|
||||
// NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
|
||||
const bool is_integer = NumTraits<T>::IsInteger;
|
||||
EIGEN_UNUSED_VARIABLE(is_integer);
|
||||
EIGEN_STATIC_ASSERT(is_integer,
|
||||
const bool is_integer_alike = internal::is_valid_index_type<T>::value;
|
||||
EIGEN_UNUSED_VARIABLE(is_integer_alike);
|
||||
EIGEN_STATIC_ASSERT(is_integer_alike,
|
||||
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
|
||||
resize(size);
|
||||
}
|
||||
|
@ -81,4 +81,17 @@ EIGEN_DECLARE_TEST(constructor)
|
||||
Array<float,3,3> a(123);
|
||||
VERIFY_IS_EQUAL(a(4), 123.f);
|
||||
}
|
||||
{
|
||||
enum { M = 12, N = 7};
|
||||
MatrixXi m1(M,N);
|
||||
VERIFY_IS_EQUAL(m1.rows(),M);
|
||||
VERIFY_IS_EQUAL(m1.cols(),N);
|
||||
ArrayXXi a1(M,N);
|
||||
VERIFY_IS_EQUAL(a1.rows(),M);
|
||||
VERIFY_IS_EQUAL(a1.cols(),N);
|
||||
VectorXi v1(M);
|
||||
VERIFY_IS_EQUAL(v1.size(),M);
|
||||
ArrayXi a2(M);
|
||||
VERIFY_IS_EQUAL(a2.size(),M);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user