| Home | Libraries | People | FAQ | More

## Class accessor

boost::histogram::indexed_range::accessor — Lightweight view to access value and index of current cell.

## Synopsis

    // 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;
      };

      // public member functions
      accessor & operator=(const accessor &);
      template<typename T> accessor & operator=(const T &);
      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;
    };

## Description

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, butindexed_range::iterator can be stored.

### `accessor` public member functions

1.     accessor & operator=(const accessor & o);

2.     template<typename T> accessor & operator=(const T & x);

3.     value_reference get() const noexcept;

   Returns the cell reference.

4.     value_reference operator*() const noexcept;

   Returns the cell reference.

5.     value_iterator operator->() const noexcept;

   Access fields and methods of the cell object.

6.     axis::index_type index(unsigned d = 0) const noexcept;

   Access current index.

   Parameters: |
   `d` | axis dimension.

7.     index_view indices() const noexcept;

   Access indices as an iterable range.

8.     template<unsigned N = 0>
         decltype(auto) bin(std::integral_constant< unsigned, N > = {}) const;

   Access current bin.

   Template Parameters: |
   `N` | axis dimension.

9.     decltype(auto) bin(unsigned d) const;

   Access current bin.

   Parameters: |
   `d` | axis dimension.

10.     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.

11.     bool operator<(const accessor & o) noexcept;

12.     bool operator>(const accessor & o) noexcept;

13.     bool operator==(const accessor & o) noexcept;

14.     bool operator!=(const accessor & o) noexcept;

15.     bool operator<=(const accessor & o) noexcept;

16.     bool operator>=(const accessor & o) noexcept;

17.     template<typename U> bool operator<(const U & o) const noexcept;

18.     template<typename U> bool operator>(const U & o) const noexcept;

19.     template<typename U> bool operator==(const U & o) const noexcept;

20.     template<typename U> bool operator!=(const U & o) const noexcept;

21.     template<typename U> bool operator<=(const U & o) const noexcept;

22.     template<typename U> bool operator>=(const U & o) const noexcept;

23.     operator value_type() const noexcept;