mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 09:49:03 +08:00
Add convenience method constexpr std::size_t size() const
to Eigen::IndexList
This commit is contained in:
parent
fbc62f7df9
commit
18eab8f997
@ -305,6 +305,11 @@ struct IndexList : internal::IndexTuple<FirstType, OtherTypes...> {
|
|||||||
return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::set(i, *this, value);
|
return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::set(i, *this, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr std::size_t size() const {
|
||||||
|
return 1 + sizeof...(OtherTypes);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr IndexList(const internal::IndexTuple<FirstType, OtherTypes...>& other) : internal::IndexTuple<FirstType, OtherTypes...>(other) { }
|
EIGEN_DEVICE_FUNC constexpr IndexList(const internal::IndexTuple<FirstType, OtherTypes...>& other) : internal::IndexTuple<FirstType, OtherTypes...>(other) { }
|
||||||
EIGEN_DEVICE_FUNC constexpr IndexList(FirstType& first, OtherTypes... other) : internal::IndexTuple<FirstType, OtherTypes...>(first, other...) { }
|
EIGEN_DEVICE_FUNC constexpr IndexList(FirstType& first, OtherTypes... other) : internal::IndexTuple<FirstType, OtherTypes...>(first, other...) { }
|
||||||
EIGEN_DEVICE_FUNC constexpr IndexList() : internal::IndexTuple<FirstType, OtherTypes...>() { }
|
EIGEN_DEVICE_FUNC constexpr IndexList() : internal::IndexTuple<FirstType, OtherTypes...>() { }
|
||||||
|
@ -24,6 +24,8 @@ static void test_static_index_list()
|
|||||||
VERIFY_IS_EQUAL(static_cast<Index>(reduction_axis[1]), 1);
|
VERIFY_IS_EQUAL(static_cast<Index>(reduction_axis[1]), 1);
|
||||||
VERIFY_IS_EQUAL(static_cast<Index>(reduction_axis[2]), 2);
|
VERIFY_IS_EQUAL(static_cast<Index>(reduction_axis[2]), 2);
|
||||||
|
|
||||||
|
VERIFY_IS_EQUAL(reduction_axis.size(), std::size_t(3));
|
||||||
|
|
||||||
EIGEN_STATIC_ASSERT((internal::array_get<0>(reduction_axis) == 0), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
EIGEN_STATIC_ASSERT((internal::array_get<0>(reduction_axis) == 0), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
EIGEN_STATIC_ASSERT((internal::array_get<1>(reduction_axis) == 1), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
EIGEN_STATIC_ASSERT((internal::array_get<1>(reduction_axis) == 1), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
EIGEN_STATIC_ASSERT((internal::array_get<2>(reduction_axis) == 2), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
EIGEN_STATIC_ASSERT((internal::array_get<2>(reduction_axis) == 2), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user