From f1ac91324601fd28b37bcb45df776a80993da7ee Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Sun, 13 Jan 2019 23:18:39 +0100 Subject: [PATCH] better solution for adding optional update method when axis has growth --- include/boost/histogram/axis/integer.hpp | 84 ++++++++++++++--------- include/boost/histogram/detail/meta.hpp | 4 +- include/boost/histogram/serialization.hpp | 2 +- include/boost/histogram/unsafe_access.hpp | 8 +-- test/histogram_growing_test.cpp | 2 - test/meta_test.cpp | 12 +--- 6 files changed, 57 insertions(+), 55 deletions(-) diff --git a/include/boost/histogram/axis/integer.hpp b/include/boost/histogram/axis/integer.hpp index 0ca77a7c..940d75c8 100644 --- a/include/boost/histogram/axis/integer.hpp +++ b/include/boost/histogram/axis/integer.hpp @@ -22,29 +22,21 @@ namespace boost { namespace histogram { namespace axis { -/** Axis for an interval of integer values with unit steps. - * - * Binning is a O(1) operation. This axis operates - * faster than a regular axis. - */ -template -class integer : public base, - public iterator_mixin> { + +template +class integer_base : public base, + public iterator_mixin> { static_assert(!test(Options, option::circular) || !test(Options, option::underflow), "circular axis cannot have underflow"); static_assert(!std::is_integral::value || std::is_same::value, "integer axis requires type floating point type or int"); using base_type = base; - -public: using metadata_type = MetaData; using value_type = IntType; - -private: using index_type = std::conditional_t::value, int, double>; public: - integer() = default; + integer_base() = default; /** Construct over semi-open integer interval [start, stop). * @@ -53,13 +45,13 @@ public: * \param metadata description of the axis. * \param options extra bin options. */ - integer(value_type start, value_type stop, metadata_type m = {}) + integer_base(value_type start, value_type stop, metadata_type m = {}) : base_type(static_cast(stop - start > 0 ? stop - start : 0), std::move(m)) , min_(start) {} /// Constructor used by algorithm::reduce to shrink and rebin. - integer(const integer& src, int begin, int end, unsigned merge) + integer_base(const integer_base& src, int begin, int end, unsigned merge) : base_type(end - begin, src.metadata()), min_(src.min_ + begin) { if (merge > 1) BOOST_THROW_EXCEPTION(std::invalid_argument("cannot merge bins for integer axis")); @@ -72,11 +64,6 @@ public: return index_impl(std::is_floating_point(), x); } - template