//: C06:Transform.cpp {-mwcc} // 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. // Use of STL transform() algorithm. //{L} Counted #include #include #include #include "Counted.h" using namespace std; template T* deleteP(T* x) { delete x; return 0; } template struct Deleter { T* operator()(T* x) { delete x; return 0; } }; int main() { CountedVector cv("one"); transform(cv.begin(), cv.end(), cv.begin(), deleteP); CountedVector cv2("two"); transform(cv2.begin(), cv2.end(), cv2.begin(), Deleter()); } ///:~