//: :purge.h // 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. // Delete pointers in an STL sequence container. #ifndef PURGE_H #define PURGE_H #include template void purge(Seq& c) { typename Seq::iterator i; for(i = c.begin(); i != c.end(); ++i) { delete *i; *i = 0; } } // Iterator version: template void purge(InpIt begin, InpIt end) { while(begin != end) { delete *begin; *begin = 0; ++begin; } } #endif // PURGE_H ///:~