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

Added `cbegin()` and `cend()` to most containers #748

Merged
merged 8 commits into from Sep 3, 2017

Conversation

Projects
None yet
3 participants
@dcdillon
Contributor

dcdillon commented Sep 2, 2017

This PR should serve as the baseline for implementation of cbegin()/cend() functions on Rcpp containers. It preserves functionality as-is for most things and is simply an addition of new functions, but it also sets the table for getting const correctness across the board.

Conspicuously missing is MatrixRow because I forgot and we already ran extensive testing on what's here. This will be addressed in a future PR.

Fundamentally, we did two things:

  1. Created the concept of both iterator and const_iterator within VectorBase. It always had iterator but it wasn't really an iterator. It was called iterator and behaved like a const_iterator except that instead of returning const & it returned items by value on dereferencing. This functionality has been preserved because returning & and const & causes issues with the various proxy classes. This will need to be addressed in a future PR. Currently VectorBase only returns
    const_iterator from the begin(), end(), cbegin(), cend() functions which is consistent with previous behavior.
  2. Added cbegin()/cend() function to Vector and its derivatives. This is consistent with current behavior, but does not change whether the const_iterator is actually const in the case of proxy classes (specifically const_string_proxy which can be assigned to against all reason). This too will be changed in a future PR.
@coatless

This comment has been minimized.

Show comment
Hide comment
@coatless

coatless Aug 16, 2017

Owner

Should this be commented out?

Owner

coatless commented on inst/include/Rcpp/vector/VectorBase.h in ccb2db2 Aug 16, 2017

Should this be commented out?

This comment has been minimized.

Show comment
Hide comment
@dcdillon

dcdillon Aug 16, 2017

Collaborator

Yes. There is no non const iterator currently possible. I'm working on that.

Collaborator

dcdillon replied Aug 16, 2017

Yes. There is no non const iterator currently possible. I'm working on that.

eddelbuettel added a commit to RcppCore/rcpp-logs that referenced this pull request Sep 3, 2017

@eddelbuettel eddelbuettel merged commit cb54c77 into RcppCore:master Sep 3, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment