...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::histogram::indexed — Generates an indexed range of forward iterators over the histogram cells.
// In header: <boost/histogram/indexed.hpp> template<typename Histogram> auto indexed(Histogram && hist, coverage cov = coverage::inner);
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: |
|
||||
Returns: |