This forum has been archived. All content is frozen. Please use KDE Discuss instead.

ptrdiff_t vs size_t for MatrixBase::Index versus std::vector

Tags: None
(comma "," separated)
daviddoria
Registered Member
Posts
46
Karma
0
OS
I see that the Index type of Eigen::MatrixBase is a ptrdiff_t (signed) . If I want to write a template function that can operate on either a std::vector or an Eigen::VectorXf, I get warnings about comparing signed/unsigned types because a loop counter for std::vector needs to be size_t (unsigned) and a loop counter for Eigen::VectorXf needs to be ptrdiff_t . Is there anything that can be done to make it work (warning free) with both?

Thanks,

David
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
well you can do something like:

for(ptrdiff_t i=0; i<ptrdiff_t(vec.size()); ++i) ....


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell