1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef BOOST_HISTOGRAM_AXIS_INTERVAL_VIEW_HPP
- #define BOOST_HISTOGRAM_AXIS_INTERVAL_VIEW_HPP
- #include <boost/histogram/fwd.hpp>
- namespace boost {
- namespace histogram {
- namespace axis {
- template <class Axis>
- class interval_view {
- public:
- interval_view(const Axis& axis, index_type idx) : axis_(axis), idx_(idx) {}
-
- interval_view(Axis&& axis, index_type idx) = delete;
-
- decltype(auto) lower() const noexcept { return axis_.value(idx_); }
-
- decltype(auto) upper() const noexcept { return axis_.value(idx_ + 1); }
-
- decltype(auto) center() const noexcept { return axis_.value(idx_ + 0.5); }
-
- decltype(auto) width() const noexcept { return upper() - lower(); }
- template <class BinType>
- bool operator==(const BinType& rhs) const noexcept {
- return lower() == rhs.lower() && upper() == rhs.upper();
- }
- template <class BinType>
- bool operator!=(const BinType& rhs) const noexcept {
- return !operator==(rhs);
- }
- private:
- const Axis& axis_;
- const index_type idx_;
- };
- }
- }
- }
- #endif
|