C++憤恨者札記10——bind2nd示例

#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//can't use reference arg 
//bool Filter( const wstring& s, const wstring& pattern )
bool Filter( const wstring s, const wstring pattern )
{
	return wstring::npos != s.find( pattern );
}

void main()
{
	vector<wstring> vec;

	vec.push_back( L"AAA" );
	vec.push_back( L"BBB" );
	vec.push_back( L"CCC" );

	remove_if( vec.begin(), vec.end(), bind2nd( ptr_fun(Filter), L"C" ) );
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章