From 1d3f3d7a0c53ede7416a438ef397565bce85e5d5 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Wed, 22 Mar 2017 22:39:55 +0100 Subject: [PATCH] simpler, dont expose axes_type, provide for_each_axis instead --- include/boost/histogram/detail/meta.hpp | 6 +++++ include/boost/histogram/detail/variance.hpp | 8 ++----- include/boost/histogram/dynamic_histogram.hpp | 17 +++++++------ .../histogram/histogram_ostream_operators.hpp | 24 ++++--------------- include/boost/histogram/static_histogram.hpp | 12 ++++++---- .../histogram/storage/adaptive_storage.hpp | 10 ++++---- include/boost/histogram/utility.hpp | 17 +++++++++++++ src/python/histogram.cpp | 11 ++++----- 8 files changed, 57 insertions(+), 48 deletions(-) diff --git a/include/boost/histogram/detail/meta.hpp b/include/boost/histogram/detail/meta.hpp index c8d15700..79a3edc6 100644 --- a/include/boost/histogram/detail/meta.hpp +++ b/include/boost/histogram/detail/meta.hpp @@ -49,6 +49,12 @@ template ()))> struct is_sequence {}; +struct histogram_tag {}; + +template +struct is_histogram {}; + template struct intersection { diff --git a/include/boost/histogram/detail/variance.hpp b/include/boost/histogram/detail/variance.hpp index d4f549e0..8388ee53 100644 --- a/include/boost/histogram/detail/variance.hpp +++ b/include/boost/histogram/detail/variance.hpp @@ -13,14 +13,10 @@ namespace boost { namespace histogram { namespace detail { -// standard Poisson estimate -template -Value variance(Value k) { return k; } - namespace { template typename std::enable_if< - (has_weight_support::value), + has_weight_support::value, typename Storage::value_type >::type variance_impl(const Storage& s, std::size_t i) @@ -32,7 +28,7 @@ namespace { typename Storage::value_type >::type variance_impl(const Storage& s, std::size_t i) - { return variance(s.value(i)); } + { return s.value(i); } // standard Poisson estimate } template diff --git a/include/boost/histogram/dynamic_histogram.hpp b/include/boost/histogram/dynamic_histogram.hpp index d928c0c2..0fd7e4f6 100644 --- a/include/boost/histogram/dynamic_histogram.hpp +++ b/include/boost/histogram/dynamic_histogram.hpp @@ -13,12 +13,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include #include @@ -35,9 +34,12 @@ class dynamic_histogram static_assert(!mpl::empty::value, "at least one axis required"); public: + using histogram_tag = detail::histogram_tag; using axis_type = typename make_variant_over::type; - using axes_type = std::vector; using value_type = typename Storage::value_type; +private: + using axes_type = std::vector; +public: dynamic_histogram() = default; @@ -275,8 +277,6 @@ public: return axes_[N]; } - const axes_type& axes() const { return axes_; } - private: axes_type axes_; Storage storage_; @@ -322,11 +322,14 @@ private: } } + friend struct storage_access; + + template + friend void for_each_axis(const dynamic_histogram&, Visitor&); + template friend class dynamic_histogram; - friend struct storage_access; - template friend void serialize(Archiv&, dynamic_histogram&, unsigned); }; diff --git a/include/boost/histogram/histogram_ostream_operators.hpp b/include/boost/histogram/histogram_ostream_operators.hpp index 59d542ab..6938cb4a 100644 --- a/include/boost/histogram/histogram_ostream_operators.hpp +++ b/include/boost/histogram/histogram_ostream_operators.hpp @@ -7,14 +7,10 @@ #ifndef _BOOST_HISTOGRAM_HISTOGRAM_STREAMER_HPP_ #define _BOOST_HISTOGRAM_HISTOGRAM_STREAMER_HPP_ -#include #include #include #include -#include -#include -#include -#include +#include #include namespace boost { @@ -30,23 +26,13 @@ namespace detail { }; } -template -inline std::ostream& operator<<(std::ostream& os, const static_histogram& h) +template