Strided Iterator and Range

The strided iterator adapts multidimensional buffers to work with the C++ standard library and range-based for-loops. Given a pointer or iterator into a multidimensional data buffer, one can generate an iterator range using make_strided to construct strided versions of the standard library's begin and end. For constructing range-based for-loops, a strided_range class is provided. These help authors to avoid integer-based indexing, which in some cases can impede algorithm performance and introduce indexing errors. This library exists primarily to expose the header file to other R projects.

Timothy H. Keitt 2018-01-10

"I don't think he knows about second breakfast" - Meriadoc 'Merry' Brandybuck

Adapting multidimensional legacy buffers to the C++ standard library is difficult owing to a lack of strided (address-skipping) iterators. Strider provides an address-skipping pointer adapter. It can be used to scan multidimensional data along any desired margin using the standard library algorithms.

This code snippet computes row sums of a matrix.

  for_each(make_strided(begin(x), nr), make_strided(end(x)), [&](const double& y) {
    transform(&y, &y + nr, begin(res), begin(res), plus<double>()); });

It is cache and compiler friendly and runs nearly four times faster than R's built-in rowSums function. See the vignette for details.

The header file is stand-alone and can be used separate from R. It relies on the Boost iterator library.


CRAN status Travis build status AppVeyor Build Status Coverage status


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1 by Tim Keitt, a year ago

Report a bug at

Browse source code at

Authors: Tim Keitt [aut, cre]

Documentation:   PDF Manual  

GPL (>= 2) license

Imports Rcpp

Suggests knitr, rmarkdown, testthat, microbenchmark, ggplot2, dplyr, covr

Linking to Rcpp, BH

System requirements: C++11

Linked to by kdtools.

See at CRAN