| Home | Libraries | People | FAQ | More

## 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: |
`hist` | Reference to the histogram.
`cov` | Iterate over all or only inner bins (optional, default: inner).
Returns: | indexed_range