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
Read-only matrix indexing operators and iterator methods are not const #234
Comments
I haven't tried the updated |
The regular non-writable classes are essentially equivalent to a Mutable classes require copying the data on construction, so having a more explicit difference than just constness was deemed worthwhile. Basically I wanted people to default to using the read-only classes, and use the writable ones only where truly necessary. Relying on user to specifying an object as const would have done the opposite, people would by default have been using a mutable class, which would then result in many more data copies in practice. It is also not possible to have const and non-const constructors, which would mean we would have to defer copying until later. I wanted to avoid this as I find it easier to reason about copies when they are done eagerly at object construction. |
@jimhester Thanks for the explanation, now I understand it better. So over time more methods of classes in non- |
yeah, they probably should basically all be |
The index operator, call operator, begin and end methods should be const for a read-only matrix.
All statements in the below snippet are compile errors.
The text was updated successfully, but these errors were encountered: