| Home | Libraries | People | FAQ | More

## Class template unlimited_storage

boost::histogram::unlimited_storage — Memory-efficient storage for integral counters which cannot overflow.

## Synopsis

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

    template<typename Allocator>
    class unlimited_storage {
    public:
      // types
      typedef unspecified const_reference;
      typedef unspecified reference;
      typedef Allocator   allocator_type;
      typedef double      value_type;
      typedef unspecified large_int;
      typedef unspecified const_iterator;
      typedef unspecified iterator;

      // public member functions
      explicit unlimited_storage(const allocator_type & = {});
      unlimited_storage(const unlimited_storage &) = default;
      unlimited_storage & operator=(const unlimited_storage &) = default;
      unlimited_storage(unlimited_storage &&) = default;
      unlimited_storage & operator=(unlimited_storage &&) = default;
      template<typename Iterable> explicit unlimited_storage(const Iterable &);
      template<typename Iterable> unlimited_storage & operator=(const Iterable &);
      allocator_type get_allocator() const;
      void reset(std::size_t);
      std::size_t size() const noexcept;
      reference operator[](std::size_t) noexcept;
      const_reference operator[](std::size_t) const noexcept;
      bool operator==(const unlimited_storage &) const noexcept;
      template<typename Iterable> bool operator==(const Iterable &) const;
      unlimited_storage & operator*=(const double);
      iterator begin() noexcept;
      iterator end() noexcept;
      const_iterator begin() const noexcept;
      const_iterator end() const noexcept;
      template<typename Archive> void serialize(Archive &, unsigned);

      // public data members
      static bool has_threading_support;
    };

## Description

This storage provides a no-overflow-guarantee if the counters are incremented with integer weights. It maintains a contiguous array of elemental counters, one for each cell. If an operation is requested which would overflow a counter, the array is replaced with another of a wider integral type, then the operation is executed. The storage uses integers of 8, 16, 32, 64 bits, and then switches to a multiprecision integral type, similar to those in Boost.Multiprecision.

A scaling operation or adding a floating point number triggers a conversion of the elemental counters into doubles, which voids the no-overflow-guarantee.

### `unlimited_storage` public member functions

1.     explicit unlimited_storage(const allocator_type & a = {});

2.     unlimited_storage(const unlimited_storage &) = default;

3.     unlimited_storage & operator=(const unlimited_storage &) = default;

4.     unlimited_storage(unlimited_storage &&) = default;

5.     unlimited_storage & operator=(unlimited_storage &&) = default;

6.     template<typename Iterable> explicit unlimited_storage(const Iterable & s);

7.     template<typename Iterable> unlimited_storage & operator=(const Iterable & s);

8.     allocator_type get_allocator() const;

9.     void reset(std::size_t n);

10.     std::size_t size() const noexcept;

11.     reference operator[](std::size_t i) noexcept;

12.     const_reference operator[](std::size_t i) const noexcept;

13.     bool operator==(const unlimited_storage & x) const noexcept;

14.     template<typename Iterable> bool operator==(const Iterable & iterable) const;

15.     unlimited_storage & operator*=(const double x);

16.     iterator begin() noexcept;

17.     iterator end() noexcept;

18.     const_iterator begin() const noexcept;

19.     const_iterator end() const noexcept;

20.     template<typename Archive> void serialize(Archive & ar, unsigned);