From f437d4ab4d17d80f5d422dfd727bd7834cb4256c Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Sat, 16 Jul 2016 22:07:52 -0400 Subject: [PATCH] missing header --- include/boost/histogram/storage.hpp | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/boost/histogram/storage.hpp diff --git a/include/boost/histogram/storage.hpp b/include/boost/histogram/storage.hpp new file mode 100644 index 00000000..4c8aba51 --- /dev/null +++ b/include/boost/histogram/storage.hpp @@ -0,0 +1,37 @@ +// Copyright 2015-2016 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef _BOOST_HISTOGRAM_STORAGE_HPP_ +#define _BOOST_HISTOGRAM_STORAGE_HPP_ + +#include + +namespace boost { +namespace histogram { + + template + struct static_storage { + std::vector data_; + typedef T value_t; + typedef T variance_t; + std::size_t size() const { return data_.size(); } + void allocate(std::size_t n) { data_.resize(n, 0); } + void increase(std::size_t i) { ++(data_[i]); } + value_t value(std::size_t i) const { return data_[i]; } + variance_t variance(std::size_t i) const { return data_[i]; } + bool operator==(const static_storage& other) const + { return data_ == other.data_; } + void operator+=(const static_storage& other) + { + for (std::size_t i = 0, n = size(); i < n; ++i) + data_[i] += other.data_[i]; + } + }; + +} +} + +#endif