MCPcopy Create free account
hub / github.com/boostorg/histogram / main

Function main

examples/guide_histogram_serialization.cpp:11–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace bh = boost::histogram;
10
11int main() {
12 auto a = bh::make_static_histogram(bh::axis::regular<>(3, -1, 1, "r"),
13 bh::axis::integer<>(0, 2, "i"));
14 a(0.5, 1);
15
16 std::string buf; // holds persistent representation
17
18 // store histogram
19 {
20 std::ostringstream os;
21 boost::archive::text_oarchive oa(os);
22 oa << a;
23 buf = os.str();
24 }
25
26 auto b = decltype(a)(); // create a default-constructed second histogram
27
28 std::cout << "before restore " << (a == b) << std::endl;
29 // prints: before restore 0
30
31 // load histogram
32 {
33 std::istringstream is(buf);
34 boost::archive::text_iarchive ia(is);
35 ia >> b;
36 }
37
38 std::cout << "after restore " << (a == b) << std::endl;
39 // prints: after restore 1
40}
41
42//]

Callers

nothing calls this directly

Calls 1

make_static_histogramFunction · 0.85

Tested by

no test coverage detected