MCPcopy Create free account
hub / github.com/boostorg/histogram / base

Class base

include/boost/histogram/axis/base.hpp:30–72  ·  view source on GitHub ↗

Base class for all axes

Source from the content-addressed store, hash-verified

28
29/// Base class for all axes
30class base {
31public:
32 /// Returns the number of bins without overflow/underflow.
33 int size() const noexcept { return size_; }
34 /// Returns the number of bins, including overflow/underflow if enabled.
35 int shape() const noexcept { return shape_; }
36 /// Returns number of extra bins to count under- or overflow.
37 int uoflow() const noexcept { return shape_ - size_; }
38
39protected:
40 base(unsigned size, axis::uoflow_type uo)
41 : size_(size), shape_(size + static_cast<int>(uo)) {
42 if (size_ == 0) { throw std::invalid_argument("bins > 0 required"); }
43 }
44
45 base() = default;
46 base(const base&) = default;
47 base& operator=(const base&) = default;
48 base(base&& rhs) : size_(rhs.size_), shape_(rhs.shape_) {
49 rhs.size_ = 0;
50 rhs.shape_ = 0;
51 }
52 base& operator=(base&& rhs) {
53 if (this != &rhs) {
54 size_ = rhs.size_;
55 shape_ = rhs.shape_;
56 rhs.size_ = 0;
57 rhs.shape_ = 0;
58 }
59 return *this;
60 }
61
62 bool operator==(const base& rhs) const noexcept {
63 return size_ == rhs.size_ && shape_ == rhs.shape_;
64 }
65
66private:
67 int size_ = 0, shape_ = 0;
68
69 friend class ::boost::serialization::access;
70 template <class Archive>
71 void serialize(Archive&, unsigned);
72};
73
74/// Base class with a label
75template <typename Allocator>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected