//: C06:PtrFun1.cpp // From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison. // (c) 1995-2004 MindView, Inc. All Rights Reserved. // See source code use permissions stated in the file 'License.txt', // distributed with the code package available at www.MindView.net. // Using ptr_fun() with a unary function. #include #include #include #include #include #include using namespace std; int d[] = { 123, 94, 10, 314, 315 }; const int DSZ = sizeof d / sizeof *d; bool isEven(int x) { return x % 2 == 0; } int main() { vector vb; transform(d, d + DSZ, back_inserter(vb), not1(ptr_fun(isEven))); copy(vb.begin(), vb.end(), ostream_iterator(cout, " ")); cout << endl; // Output: 1 0 0 0 1 } ///:~