| 21 | bool is_odd_int(int x) { return x % 2 != 0; } |
| 22 | |
| 23 | void Test_example_KeepIf() |
| 24 | { |
| 25 | typedef std::vector<int> Ints; |
| 26 | Ints values = { 24, 11, 65, 44, 80, 18, 73, 90, 69, 18 }; |
| 27 | |
| 28 | { // Version 1: hand written range based for loop |
| 29 | Ints odds; |
| 30 | for (int x : values) |
| 31 | if (is_odd_int(x)) |
| 32 | odds.push_back(x); |
| 33 | } |
| 34 | |
| 35 | { // Version 2: STL |
| 36 | Ints odds; |
| 37 | std::copy_if(std::begin(values), std::end(values), |
| 38 | std::back_inserter(odds), is_odd_int); |
| 39 | } |
| 40 | |
| 41 | { // Version : FunctionalPlus |
| 42 | auto odds = fplus::keep_if(is_odd_int, values); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void run_n_times(std::function<std::vector<int>(std::vector<int>)> f, |
| 47 | std::size_t n, const std::string& name, const std::vector<int>& inList) |
nothing calls this directly
no test coverage detected