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" ) );
}

你可能感兴趣的:(bind2nd,ptr_fun)