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

Function main

src/examples/rpp/doxygen/with_latest_from.cpp:8–34  ·  view source on GitHub ↗

* @example with_latest_from.cpp **/

Source from the content-addressed store, hash-verified

6 * @example with_latest_from.cpp
7 **/
8int main()
9{
10 //! [with_latest_from]
11 rpp::source::just(1, 2, 3, 4, 5, 6)
12 | rpp::operators::with_latest_from(rpp::source::just(3, 4, 5))
13 | rpp::operators::subscribe([](std::tuple<int, int> v) { std::cout << std::get<0>(v) << ":" << std::get<1>(v) << " "; });
14 // Output: 1:3 2:4 3:5 4:5 5:5 6:5
15
16 std::cout << std::endl;
17
18 rpp::source::just(1, 2, 3)
19 | rpp::operators::with_latest_from(rpp::source::just(3, 4, 5, 6, 7, 8))
20 | rpp::operators::subscribe([](std::tuple<int, int> v) { std::cout << std::get<0>(v) << ":" << std::get<1>(v) << " "; });
21 // Output: 1:3 2:4 3:5
22 //! [with_latest_from]
23
24 std::cout << std::endl;
25
26 //! [with_latest_from custom selector]
27 rpp::source::just(1, 2, 3, 4)
28 | rpp::operators::with_latest_from([](int left, int right) { return left + right; },
29 rpp::source::just(3, 4, 5))
30 | rpp::operators::subscribe([](int v) { std::cout << v << " "; });
31 // Output: 4 6 8 9
32 //! [with_latest_from custom selector]
33 return 0;
34}

Callers

nothing calls this directly

Calls 3

justFunction · 0.85
with_latest_fromFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected