File indexing completed on 2025-01-18 09:38:10
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_HISTOGRAM_AXIS_INTERVAL_VIEW_HPP
0008 #define BOOST_HISTOGRAM_AXIS_INTERVAL_VIEW_HPP
0009
0010 #include <boost/histogram/fwd.hpp>
0011
0012 namespace boost {
0013 namespace histogram {
0014 namespace axis {
0015
0016
0017
0018
0019
0020
0021 template <class Axis>
0022 class interval_view {
0023 public:
0024 interval_view(const Axis& axis, index_type idx) : axis_(axis), idx_(idx) {}
0025
0026 interval_view(Axis&& axis, index_type idx) = delete;
0027
0028
0029 decltype(auto) lower() const noexcept { return axis_.value(idx_); }
0030
0031 decltype(auto) upper() const noexcept { return axis_.value(idx_ + 1); }
0032
0033 decltype(auto) center() const noexcept { return axis_.value(idx_ + 0.5); }
0034
0035 decltype(auto) width() const noexcept { return upper() - lower(); }
0036
0037 template <class BinType>
0038 bool operator==(const BinType& rhs) const noexcept {
0039 return lower() == rhs.lower() && upper() == rhs.upper();
0040 }
0041
0042 template <class BinType>
0043 bool operator!=(const BinType& rhs) const noexcept {
0044 return !operator==(rhs);
0045 }
0046
0047 private:
0048 const Axis& axis_;
0049 const index_type idx_;
0050 };
0051
0052 }
0053 }
0054 }
0055
0056 #endif