yo/stl/examples/bind.cc
raw| 1 | #include <iostream> |
| 2 | #include <vector> |
| 3 | #include <functional> |
| 4 | #include <algorithm> |
| 5 | |
| 6 | using namespace std; |
| 7 | |
| 8 | int main() |
| 9 | { |
| 10 | using namespace placeholders; |
| 11 | |
| 12 | vector<int> vi {1, 9, 2, 8, 3, 7, 4, 6, 5}; |
| 13 | |
| 14 | cout << count_if(vi.begin(), vi.end(), |
| 15 | bind(greater<int>(), _1, 6)) << '\n'; |
| 16 | |
| 17 | cout << count_if(vi.begin(), vi.end(), |
| 18 | bind(greater<int>(), 6, _1)) << '\n'; |
| 19 | } |