This commit is contained in:
Hans Dembinski 2018-11-28 21:40:24 +01:00
parent fbf9707874
commit be16b0f39f
3 changed files with 6 additions and 5 deletions

View File

@ -65,8 +65,8 @@ int main() {
os.setf(std::ios_base::fixed); os.setf(std::ios_base::fixed);
for (auto x : indexed(h)) { for (auto x : indexed(h)) {
os << "bin " << std::setw(2) << x[0] << " [" << std::setprecision(1) << std::setw(4) os << "bin " << std::setw(2) << x[0] << " [" << std::setprecision(1) << std::setw(4)
<< x.bin(0).lower() << ", " << std::setw(4) << x.bin(0).upper() << "): " << x.value << x.bin(0).lower() << ", " << std::setw(4) << x.bin(0).upper()
<< "\n"; << "): " << std::fixed << x.value << "\n";
} }
std::cout << os.str() << std::endl; std::cout << os.str() << std::endl;

View File

@ -12,6 +12,7 @@
#include <boost/histogram/arithmetic_operators.hpp> #include <boost/histogram/arithmetic_operators.hpp>
#include <boost/histogram/detail/axes.hpp> #include <boost/histogram/detail/axes.hpp>
#include <boost/histogram/detail/meta.hpp> #include <boost/histogram/detail/meta.hpp>
#include <boost/histogram/detail/nodiscard.hpp>
#include <boost/histogram/histogram_fwd.hpp> #include <boost/histogram/histogram_fwd.hpp>
#include <boost/mp11.hpp> #include <boost/mp11.hpp>
#include <functional> #include <functional>
@ -22,6 +23,7 @@
namespace boost { namespace boost {
namespace histogram { namespace histogram {
BOOST_HISTOGRAM_DETAIL_NODISCARD
template <typename Axes, typename Storage> template <typename Axes, typename Storage>
class histogram { class histogram {
static_assert(mp11::mp_size<Axes>::value > 0, "at least one axis required"); static_assert(mp11::mp_size<Axes>::value > 0, "at least one axis required");

View File

@ -10,6 +10,7 @@
#include <boost/histogram/axis/traits.hpp> #include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/detail/axes.hpp> #include <boost/histogram/detail/axes.hpp>
#include <boost/histogram/detail/meta.hpp> #include <boost/histogram/detail/meta.hpp>
#include <boost/histogram/detail/nodiscard.hpp>
#include <boost/histogram/histogram_fwd.hpp> #include <boost/histogram/histogram_fwd.hpp>
#include <boost/histogram/unsafe_access.hpp> #include <boost/histogram/unsafe_access.hpp>
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
@ -115,9 +116,6 @@ public:
}); });
} }
indexed_range(const indexed_range&) = default;
indexed_range& operator=(const indexed_range& rhs) = default;
const_iterator begin() const { return {*this, 0}; } const_iterator begin() const { return {*this, 0}; }
const_iterator end() const { return {*this, storage_.size()}; } const_iterator end() const { return {*this, storage_.size()}; }
@ -127,6 +125,7 @@ private:
strides_type strides_; strides_type strides_;
}; };
BOOST_HISTOGRAM_DETAIL_NODISCARD
template <typename Histogram> template <typename Histogram>
indexed_range<detail::unqual<Histogram>> indexed(Histogram&& h) { indexed_range<detail::unqual<Histogram>> indexed(Histogram&& h) {
return {std::forward<Histogram>(h)}; return {std::forward<Histogram>(h)};