forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex14_42.cpp
More file actions
22 lines (18 loc) · 742 Bytes
/
Copy pathex14_42.cpp
File metadata and controls
22 lines (18 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <functional>
int main()
{
using std::placeholders::_1;
std::vector<int> ivec { 1, 111, 1111, 11111 };
int count = std::count_if (ivec.cbegin(), ivec.cend(), std::bind(std::greater<int>(), _1, 1024));
std::cout << count << std::endl;
std::vector<std::string> svec { "pooh", "pooh", "pezy", "pooh" };
auto found = std::find_if (svec.cbegin(), svec.cend(), std::bind(std::not_equal_to<std::string>(), _1, "pooh"));
std::cout << *found << std::endl;
std::transform(ivec.begin(), ivec.end(), ivec.begin(), std::bind(std::multiplies<int>(), _1, 2));
for (int i : ivec) std::cout << i << " ";
std::cout << std::endl;
}