File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ struct map_impl : T {
171171 if (it != static_cast <T*>(map)->end ()) {
172172 it->second += u;
173173 } else {
174- map->emplace (idx, u);
174+ auto pair = map->emplace (idx, value_type{});
175+ pair.first ->second += u;
175176 }
176177 return *this ;
177178 }
@@ -183,7 +184,8 @@ struct map_impl : T {
183184 if (it != static_cast <T*>(map)->end ()) {
184185 it->second -= u;
185186 } else {
186- map->emplace (idx, -u);
187+ auto pair = map->emplace (idx, value_type{});
188+ pair.first ->second -= u;
187189 }
188190 return *this ;
189191 }
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ boost_test(TYPE run SOURCES unlimited_storage_test.cpp)
102102boost_test (TYPE run SOURCES tools_test.cpp )
103103boost_test (TYPE run SOURCES issue_327_test.cpp )
104104boost_test (TYPE run SOURCES issue_353_test.cpp )
105+ boost_test (TYPE run SOURCES issue_416_test.cpp )
105106boost_test (TYPE run SOURCES accumulators_fraction_test.cpp )
106107boost_test (TYPE run SOURCES utility_binomial_proportion_interval_test.cpp )
107108boost_test (TYPE run SOURCES utility_wald_interval_test.cpp )
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ alias cxx14 :
104104 [ run tools_test.cpp ]
105105 [ run issue_327_test.cpp ]
106106 [ run issue_353_test.cpp ]
107+ [ run issue_416_test.cpp ]
107108 [ run histogram_ostream_test.cpp : : :
108109 <testing.launcher>"set LANG=UTF" ]
109110 [ run histogram_ostream_ascii_test.cpp : : :
Original file line number Diff line number Diff line change 1+ // Copyright 2026 Hans Dembinski
2+ //
3+ // Distributed under the Boost Software License, Version 1.0.
4+ // (See accompanying file LICENSE_1_0.txt
5+ // or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+ #include < boost/core/lightweight_test.hpp>
8+ #include < boost/histogram.hpp>
9+ #include < boost/histogram/algorithm/sum.hpp>
10+ #include < unordered_map>
11+ #include < vector>
12+ #include " throw_exception.hpp"
13+
14+ namespace bh = boost::histogram;
15+
16+ int main () {
17+ using cell_t = bh::accumulators::weighted_sum<double >;
18+
19+ auto h = bh::make_histogram_with (std::unordered_map<std::size_t , cell_t >(),
20+ bh::axis::regular<>(10 , 0.0 , 1.0 ));
21+
22+ const std::vector<double > values = {0.2 , 0.3 };
23+ const std::vector<double > weights = {1.0 , 1.0 };
24+ h.fill (values, bh::weight (weights));
25+
26+ const auto s = bh::algorithm::sum (h);
27+ BOOST_TEST_EQ (s.value (), 2.0 );
28+ BOOST_TEST_EQ (s.variance (), 2.0 );
29+
30+ return boost::report_errors ();
31+ }
You can’t perform that action at this time.
0 commit comments