Debian Codegraph @

yo/stl/examples/negate.cc

raw
1 #include <iostream>
2 #include <string>
3 #include <functional>
4 #include <algorithm>
5 using namespace std;
6
7 int main(int argc, char **argv)
8 {
9 int iArr[] = { 1, -2, 3, -4, 5, -6 };
10
11 transform(iArr, iArr + 6, iArr, negate<int>());
12
13 for (int idx = 0; idx < 6; ++idx)
14 cout << iArr[idx] << ", ";
15 cout << '\n';
16 }
17 // Displays: -1, 2, -3, 4, -5, 6,