Skip to content

Conversation

dcdillon
Copy link
Contributor

@dcdillon 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants