Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Function template indexed

boost::histogram::indexed — Generates and indexed range forward iterators over a rectangular region of histogram cells.


// In header: <boost/histogram/indexed.hpp>

template<typename Histogram, typename Iterable> 
  auto indexed(Histogram && hist, Iterable && range);


Use this in a range-based for loop. Example:

auto hist = make_histogram(axis::integer<>(0, 4), axis::integer<>(2, 6));
axis::index_type range[2] = {{1, 3}, {0, 2}};
for (auto&& x : indexed(hist, range)) { ... }

This skips the first and last index of the first axis, and the last two indices of the second.



Reference to the histogram.


Iterable over items with two axis::index_type values, which mark the begin and end index of each axis. The length of the iterable must be equal to the rank of the histogram. The begin index must be smaller than the end index. Index ranges wider than the actual range are reduced to the actual range including underflow and overflow indices.