| Home | Libraries | People | FAQ | More

## Class template polymorphic_bin

boost::histogram::axis::polymorphic_bin — Holds the bin data of an axis::variant.

## Synopsis

    // In header: <boost/histogram/axis/polymorphic_bin.hpp>

    template<typename RealType>
    class polymorphic_bin {
    public:

      // public member functions
      polymorphic_bin(value_type, value_type);
      operator const value_type &() const noexcept;
      value_type lower() const noexcept;
      value_type upper() const noexcept;
      value_type center() const noexcept;
      value_type width() const noexcept;
      template<typename BinType> bool operator==(const BinType &) const noexcept;
      template<typename BinType> bool operator!=(const BinType &) const noexcept;
      bool is_discrete() const noexcept;
    };

## Description

The interface is a superset of the axis::interval_view class. In addition, the object is implicitly convertible to the value type, returning the equivalent of a call tolower(). For discrete axes,lower() ==upper(), andwidth() returns zero.

This is not a view like axis::interval_view for two reasons.

- Sequential calls to lower() andupper() would have to each loop through the variant types. This is likely to be slower than filling all the data in one loop.

- polymorphic_bin may be created from a temporary instance ofaxis::variant, like in the call histogram::axis(0). Storing a reference to the axis would result in a dangling reference. Rather than specialing the code to handle this, it seems easier to just use a value instead of a view.

### `polymorphic_bin` public member functions

1.     polymorphic_bin(value_type lower, value_type upper);

2.     operator const value_type &() const noexcept;

   Implicitly convert to bin value (for axis with discrete values).

3.     value_type lower() const noexcept;

   Return lower edge of bin.

4.     value_type upper() const noexcept;

   Return upper edge of bin.

5.     value_type center() const noexcept;

   Return center of bin.

6.     value_type width() const noexcept;

   Return width of bin.

7.     template<typename BinType> bool operator==(const BinType & rhs) const noexcept;

8.     template<typename BinType> bool operator!=(const BinType & rhs) const noexcept;

9.     bool is_discrete() const noexcept;

   Return true if bin is discrete.