MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rpp/doxygen/scan.cpp:9–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 **/
8
9int main()
10{
11 //! [scan]
12 rpp::source::just(1, 2, 3)
13 | rpp::operators::scan(10, std::plus<int>{})
14 | rpp::operators::subscribe([](int v) { std::cout << v << std::endl; });
15 // Output: 10 11 13 16
16 //! [scan]
17
18 //! [scan_vector]
19 rpp::source::just(1, 2, 3)
20 | rpp::operators::scan(std::vector<int>{}, [](std::vector<int>&& seed, int new_value) {
21 seed.push_back(new_value);
22 return std::move(seed);
23 })
24 | rpp::operators::subscribe([](const std::vector<int>& v) {
25 std::cout << "vector: ";
26 for (int val : v)
27 std::cout << val << " ";
28 std::cout << std::endl;
29 });
30 // Output: vector:
31 // vector: 1
32 // vector: 1 2
33 // vector: 1 2 3
34 //! [scan_vector]
35
36 //! [scan_no_seed]
37 rpp::source::just(1, 2, 3)
38 | rpp::operators::scan(std::plus<int>{})
39 | rpp::operators::subscribe([](int v) { std::cout << v << std::endl; });
40 // Output: 1 3 6
41 //! [scan_no_seed]
42 return 0;
43}

Callers

nothing calls this directly

Calls 4

justFunction · 0.85
scanFunction · 0.85
subscribeFunction · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected