Boost C++ Libraries

...one 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 to view this page for the latest version.
PrevUpHomeNext

Function template indexed

boost::histogram::indexed — Generates an indexed range of forward iterators over the histogram cells.

Synopsis

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


template<typename Histogram> 
  auto indexed(Histogram && hist, coverage cov = coverage::inner);

Description

Use this in a range-based for loop:

for (auto&& x : indexed(hist)) { ... }

This generates an optimized loop which is nearly always faster than a hand-written loop over the histogram cells. The iterators dereference to an indexed_range::accessor, which has methods to query the current indices and bins and acts like a pointer to the cell value. The returned iterators are forward iterators. They can be stored in a container, but may not be used after the life-time of the histogram ends.

Parameters:

cov

Iterate over all or only inner bins (optional, default: inner).

hist

Reference to the histogram.

Returns:

indexed_range


PrevUpHomeNext