yo/stl/examples/adaptors.cc
raw| 1 | #include <iostream> |
| 2 | #include <functional> |
| 3 | #include <algorithm> |
| 4 | #include <vector> |
| 5 | using namespace std; |
| 6 | |
| 7 | int main(int argc, char **argv) |
| 8 | { |
| 9 | int iArr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
| 10 | |
| 11 | cout << count_if(iArr, iArr + 10, bind2nd(less_equal<int>(), 6)) << |
| 12 | ' '; |
| 13 | cout << count_if(iArr, iArr + 10, bind2nd(not2(greater<int>()), 6)) << |
| 14 | ' '; |
| 15 | cout << count_if(iArr, iArr + 10, not1(bind2nd(greater<int>(), 6))) << |
| 16 | '\n'; |
| 17 | } |
| 18 | // Displays: 6 6 6 |