64,648
社区成员
发帖
与我相关
我的任务
分享
//...
//
//struct W
//{
// const R fun() const;
//};
//bool operator == ( const W& lhs, const W& rhs );
//bool operator > ( const W& lhs, const W& rhs );
//bool operator < ( const W& lhs, const W& rhs );
//
struct R
{
//......
};
bool operator == ( const R& lhs, const R& rhs );
bool operator > ( const R& lhs, const R& rhs );
bool operator < ( const R& lhs, const R& rhs );
struct S
{
const R fun() const;
//...
};
bool operator == ( const S& lhs, const S& rhs );
bool operator > ( const S& lhs, const S& rhs );
bool operator < ( const S& lhs, const S& rhs );
struct T
{
//...
const S fun() const;
};
S _s;
R _r;
vector<T*> vt;
//1) 在vt中寻求一个vector<T*>::iterator pos,满足 (*pos) -> fun() == _s;
//i) 在vt中寻求一个vector<T*>::iterator pos,满足 (*pos) -> fun() -> fun() == _r;
//ii) ......
//2) 在vt中寻求一个vector<T*>::iterator pos,满足S s_ = (*pos) -> fun() 比其它元素的要大(或者小)
//i) 在vt中寻求一个vector<T*>::iterator pos,满足R r_ = (*pos) -> fun() -> fun() 比其它元素的要大(或者小)
//ii) ......
//要求一行写完,不定义functor或者function
//可以使用 boost中的 lambda、bind 等类库
//没有函数式编程经验,自己写了好几次都有问题
226 const std::set<Unit*>::const_iterator pos =
227 //find_if( unit.begin(), unit.end(), is_overload() );
228 find_if( unit.begin(), unit.end(), bind(&Unit::getType, _1) == UnitTypes::Zerg_Overlord );