Are the standard library functions pertinent to both sequence containers and
associative containers?
For example, if "find_if", "remove_if" , etc... valid for both lists, deques,
vectors, sets, and maps?
I know that the word "iterator" is typedef'd from something for everyone of
these containers so I was curious if all these functions are valid.
On the same note, should I use "find_if" or "remove_if" for the following
template:
template <class AssociativeCont ainer, class Predicate>
inline void remove_if(Assoc iativeContainer & C, Predicate pred,
class associative_con tainer_tag)
{
typedef typename AssociativeCont ainer::iterator iterator;
iterator cur = c.begin();
const iterator last = c.end();
while ( (cur = std::find_if(cu r, last, pred)) != last)
{
iterator tmp = cur++;
c.erase(tmp);
}
}
associative containers?
For example, if "find_if", "remove_if" , etc... valid for both lists, deques,
vectors, sets, and maps?
I know that the word "iterator" is typedef'd from something for everyone of
these containers so I was curious if all these functions are valid.
On the same note, should I use "find_if" or "remove_if" for the following
template:
template <class AssociativeCont ainer, class Predicate>
inline void remove_if(Assoc iativeContainer & C, Predicate pred,
class associative_con tainer_tag)
{
typedef typename AssociativeCont ainer::iterator iterator;
iterator cur = c.begin();
const iterator last = c.end();
while ( (cur = std::find_if(cu r, last, pred)) != last)
{
iterator tmp = cur++;
c.erase(tmp);
}
}
Comment