}
有了第一个函数作为基础,第二个函数就容易理解多了.
需要注意的是,函数返回父迭代器.
举例:
template
bool equal_three( T _value1,T _value2 )
{
return_value1 == ++ _value2;
}
int main()
{
vector
vecInt.push_back( 2 );
vecInt.push_back( 5 );
vecInt.push_back( 7 );
vecInt.push_back( 3 );
vecInt.push_back( 5 );
vecInt.push_back( 4 );
vecInt.push_back( 5 );
vecInt.push_back( -17 );
vecInt.push_back( 3 );
list
lstInt.push_back( 4 );
lstInt.push_back( 3 );
vector
if (iterFind != vecInt.end() )
{
copy( iterFind,iterFind +lstInt.size(),ostream_iterator
}
cout<<"\n";
iterFind = search( vecInt.begin(),vecInt.end(),lstInt.begin(),lstInt.end());
if (iterFind != vecInt.end() )
{
copy( iterFind,iterFind +lstInt.size(),ostream_iterator
}
system( "pause");
return0;
}
3 5 4
请按任意键继续...
摘自 yuanweihuayan的专栏