Effective STL 47 Avoid producing write-only code

来源:互联网 发布:在u盘上安装linux系统 编辑:程序博客网 时间:2024/06/09 16:52

you would like to get rid of all the elements in the vector whose value is less than x and that occur after the last value at least as big as y.

vector<int> v;int x, y;...v.erase(    remove_if(v.find_if(v.rbegin(), v.rend(),bind2nd(greater_equal<int>(), y).base(), v.end(), bind2nd(less<int>(), x),     v.end()    );
typedef vector<int>::iterator VecIntIter;VectIntIter rangeBegin = find_if(v.rbegin(), v.rend(), bind2nd(greater_equal<int>()).base();v.erase(remove_if(rangeBegin, v.end(), bind2nd(less<int>(), x)), v.end());
原创粉丝点击