Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define operator[] for Vectors #595

Closed
GiulioRomualdi opened this issue Nov 9, 2019 · 2 comments
Closed

Define operator[] for Vectors #595

GiulioRomualdi opened this issue Nov 9, 2019 · 2 comments
Assignees

Comments

@GiulioRomualdi
Copy link
Member

GiulioRomualdi commented Nov 9, 2019

In order to access an element of an iDynTree vector the operator() has to be used. Having the operator[] may be useful when template functions are implemented. I.e. std:: vector<> uses the operator[] to provide the access to the elements.

I noticed that this strategy is already implemented in Eigen (check here for further details)

@traversaro
Copy link
Member

I totally agree. I think the original rationale for using operator() was to provide a consistent API with Matlab and Python (or perhaps it was Lua), in which the operator[] could not be overloaded. However, I do not think it is a problem to overload both operator() and operator[].

@traversaro
Copy link
Member

Fixed in #596 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants