- 208 名前:デフォルトの名無しさん mailto:sage [2008/09/14(日) 00:32:06 ]
- #include <iostream>
#include <list> #include <algorithm> using namespace std; class C { public: int ic; C (int c) { ic = c; } ~C() { cout << "~C" << endl; } }; struct delete_equal_to: public std::binary_function<C *, int, bool> { bool operator ()(C * p, int c) const { return (NULL != auto_ptr<C>(p->ic == c ? p: NULL).get()); } }; int main() { list<C *> mylist; mylist.push_back( new C(0) ); mylist.push_back( new C(1) ); mylist.push_back( new C(2) ); cout << mylist.size() << endl; mylist.remove_if(bind2nd(delete_equal_to(), 1)); cout << mylist.size() << endl; }
|

|