Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

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:
  // construct/copy/destruct
  polymorphic_bin(value_type, value_type);

  // public member functions
  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 to lower(). For discrete axes, lower() == upper(), and width() returns zero.

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

  • Sequential calls to lower() and upper() 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 construct/copy/destruct

  1. polymorphic_bin(value_type lower, value_type upper);

polymorphic_bin public member functions

  1. operator const value_type &() const noexcept;
    Implicitly convert to bin value (for axis with discrete values).
  2. value_type lower() const noexcept;
    Return lower edge of bin.
  3. value_type upper() const noexcept;
    Return upper edge of bin.
  4. value_type center() const noexcept;
    Return center of bin.
  5. value_type width() const noexcept;
    Return width of bin.
  6. template<typename BinType> bool operator==(const BinType & rhs) const noexcept;
  7. template<typename BinType> bool operator!=(const BinType & rhs) const noexcept;
  8. bool is_discrete() const noexcept;
    Return true if bin is discrete.

PrevUpHomeNext