add Chapter06

This commit is contained in:
Amar Mahmutbegovic
2025-05-08 23:01:29 +02:00
parent 7dab196517
commit 0ea2c43f45
8 changed files with 222 additions and 0 deletions

27
Chapter06/copy_if.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include <cstdio>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
void print_container(const auto& container) {
for(auto& elem: container) {
printf("%d ", elem);
}
printf("\r\n");
}
int main() {
std::array<int, 10> src{0};
std::array<int, 10> dst{0};
std::iota(src.begin(), src.end(), 0);
std::copy_if(src.begin(), src.end(), dst.begin(),[] (int x) {return x > 3;});
print_container(src);
print_container(dst);
return 0;
}