Added cbegin()
and cend()
to most containers
#748
Merged
+109
−49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
iterator
andconst_iterator
withinVectorBase
. It always haditerator
but it wasn't really an iterator. It was called iterator and behaved like aconst_iterator
except that instead of returningconst &
it returned items by value on dereferencing. This functionality has been preserved because returning&
andconst &
causes issues with the various proxy classes. This will need to be addressed in a future PR. CurrentlyVectorBase
only returnsconst_iterator
from thebegin(), end(), cbegin(), cend()
functions which is consistent with previous behavior.cbegin()/cend()
function toVector
and its derivatives. This is consistent with current behavior, but does not change whether theconst_iterator
is actuallyconst
in the case of proxy classes (specificallyconst_string_proxy
which can be assigned to against all reason). This too will be changed in a future PR.