C++ STL原来可以这么强大(二)

2014-11-24 12:12:45 · 作者: · 浏览: 1
cout << endl;

cout << "The string that not euqal with \"pooth\" : " << endl;
sIter = sVec.begin();
string sToCompare = "pooth";
while ((sIter = find_if(sIter, sVec.end(), bind2nd(not_equal_to(), sToCompare))) != sVec.end())
{
cout << *sIter << " ";
++sIter;
}
cout << endl << endl;


// Multiply all the value by 2
vector nVec(nVal, nVal + size);
cout << "The original val: " << endl;
for_each(nVec.begin(), nVec.end(), PrintVal());
cout << endl;
transform(nVec.begin(), nVec.end(), nVec.begin(), bind2nd(multiplies(), 2));
cout << "After multiply by 2: " << endl;
for_each(nVec.begin(), nVec.end(), PrintVal());
cout << endl;
return 0;
}


摘自 huagong_adu