mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
24 lines
477 B
C++
24 lines
477 B
C++
//[ guide_custom_minimal_axis
|
|
|
|
#include <boost/histogram.hpp>
|
|
#include <cassert>
|
|
|
|
namespace bh = boost::histogram;
|
|
|
|
// stateless axis which returns 1 if the input is even and 0 otherwise
|
|
struct minimal_axis {
|
|
int operator()(int x) const { return x % 2; }
|
|
unsigned size() const { return 2; }
|
|
};
|
|
|
|
int main() {
|
|
auto h = bh::make_histogram(minimal_axis());
|
|
|
|
h(0); h(1); h(2);
|
|
|
|
assert(h.at(0) == 2); // two even numbers
|
|
assert(h.at(1) == 1); // one uneven number
|
|
}
|
|
|
|
//]
|