MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / stl

Function stl

03.09-rangesMotivationComposability0/main.cpp:13–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13void stl()
14{
15 std::vector<int> numbers{2, 3, 4, 5, 6}; // #A
16
17 std::vector<int> oddNumbers{}; // #B
18 std::copy_if(begin(numbers), // #C
19 end(numbers),
20 std::back_inserter(oddNumbers),
21 is_odd);
22
23 std::vector<int> results{}; // #D
24 std::transform(begin(oddNumbers), // #E
25 end(oddNumbers),
26 std::back_inserter(results),
27 [](int n) { return n * 2; });
28
29 // #F
30 for(int n : results) { std::cout << n << ' '; }
31
32 std::cout << '\n';
33}
34
35int main()
36{

Callers 1

mainFunction · 0.85

Calls 1

beginFunction · 0.50

Tested by

no test coverage detected