While going through the book "Effective STL" the author gives an example of how a copy_if
could be written since this does not exist in the standard algorithms. Here is the authors version:
template <typename Input, typename Output,typename Predicate>
OutputIterator copy_if(Input begin , Input end, Output destBegin, Predicate p)
{
while(begin != end)
{
if(p(*begin)) *destBegin++=*begin;
++ begin;
}
return destBegin;
}
Now my question is how can the author use that method like this:
copy_if(widg.begin(),widg.end(),ostream_iterator<widg>(cerr,"\n"),isDefective);
My question is why isnt the template parameters being defined with copy_if (since it requires 3) such as this
copy_if<p1,p2,p3>(...)