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

Function main

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

* @example last.cpp **/

Source from the content-addressed store, hash-verified

6 * @example last.cpp
7 **/
8int main()
9{
10 //! [last]
11 rpp::source::just(1, 2, 3, 4, 5)
12 | rpp::operators::last()
13 | rpp::operators::subscribe(
14 [](const auto& v) { std::cout << "-" << v; },
15 [](const std::exception_ptr&) {},
16 []() { std::cout << "-|" << std::endl; });
17 // Source: -1-2-3-4-5--|
18 // Output: -5-|
19 //! [last]
20
21 //! [last empty]
22 rpp::source::empty<int>()
23 | rpp::operators::last()
24 | rpp::operators::subscribe(
25 [](const auto& v) { std::cout << "-" << v; },
26 [](const std::exception_ptr&) { std::cout << "-x"; },
27 []() { std::cout << "-|" << std::endl; });
28 // Source: -1-2-3-4-5--|
29 // Output: -x
30 //! [last empty]
31 return 0;
32}

Callers

nothing calls this directly

Calls 3

justFunction · 0.85
lastFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected