【初心者歓迎】C/C++室 Ver.59【環境依存OK】at TECH
【初心者歓迎】C/C++室 Ver.59【環境依存OK】 - 暇つぶし2ch208:デフォルトの名無しさん
08/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;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch