...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_range::accessor — Lightweight view to access value and index of current cell.
// In header: <boost/histogram/indexed.hpp> // Lightweight view to access value and index of current cell. class accessor { public: // member classes/structs/unions // Array-like view into the current multi-dimensional index. class index_view { public: // types typedef unspecified const_iterator; typedef const axis::index_type & const_reference; // public member functions const_iterator begin() const noexcept; const_iterator end() const noexcept; std::size_t size() const noexcept; const_reference operator[](unsigned) const noexcept; const_reference at(unsigned) const; }; // construct/copy/destruct accessor(iterator &) noexcept; accessor(const accessor &) = default; accessor & operator=(const accessor &); template<typename T> accessor & operator=(const T &); // public member functions value_reference get() const noexcept; value_reference operator *() const noexcept; value_iterator operator->() const noexcept; axis::index_type index(unsigned = 0) const noexcept; index_view indices() const noexcept; template<unsigned N = 0> decltype(auto) bin(std::integral_constant< unsigned, N > = {}) const; decltype(auto) bin(unsigned) const; double density() const; bool operator<(const accessor &) noexcept; bool operator>(const accessor &) noexcept; bool operator==(const accessor &) noexcept; bool operator!=(const accessor &) noexcept; bool operator<=(const accessor &) noexcept; bool operator>=(const accessor &) noexcept; template<typename U> bool operator<(const U &) const noexcept; template<typename U> bool operator>(const U &) const noexcept; template<typename U> bool operator==(const U &) const noexcept; template<typename U> bool operator!=(const U &) const noexcept; template<typename U> bool operator<=(const U &) const noexcept; template<typename U> bool operator>=(const U &) const noexcept; operator value_type() const noexcept; };
The methods provide access to the current cell indices and bins. It acts like a pointer to the cell value, and in a limited way also like a reference. To interoperate with the algorithms of the standard library, the accessor is implicitly convertible to a cell value. Assignments and comparisons are passed through to the cell. An accessor is coupled to its parent indexed_range::iterator. Moving the parent iterator forward also updates the linked accessor. Accessors are not copyable. They cannot be stored in containers, but indexed_range::iterator can be stored.
accessor
public member functionsvalue_reference get() const noexcept;Returns the cell reference.
value_reference operator *() const noexcept;Returns the cell reference.
value_iterator operator->() const noexcept;Access fields and methods of the cell object.
axis::index_type index(unsigned d = 0) const noexcept;Access current index.
Parameters: |
|
index_view indices() const noexcept;Access indices as an iterable range.
template<unsigned N = 0> decltype(auto) bin(std::integral_constant< unsigned, N > = {}) const;Access current bin.
Template Parameters: |
|
decltype(auto) bin(unsigned d) const;Access current bin.
Parameters: |
|
double density() const;Computes density in current cell.
The density is computed as the cell value divided by the product of bin widths. Axes without bin widths, like axis::category
, are treated as having unit bin with.
bool operator<(const accessor & o) noexcept;
bool operator>(const accessor & o) noexcept;
bool operator==(const accessor & o) noexcept;
bool operator!=(const accessor & o) noexcept;
bool operator<=(const accessor & o) noexcept;
bool operator>=(const accessor & o) noexcept;
template<typename U> bool operator<(const U & o) const noexcept;
template<typename U> bool operator>(const U & o) const noexcept;
template<typename U> bool operator==(const U & o) const noexcept;
template<typename U> bool operator!=(const U & o) const noexcept;
template<typename U> bool operator<=(const U & o) const noexcept;
template<typename U> bool operator>=(const U & o) const noexcept;
operator value_type() const noexcept;