S
sks_cpp
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 AssociativeContainer, class Predicate>
inline void remove_if(AssociativeContainer& C, Predicate pred,
class associative_container_tag)
{
typedef typename AssociativeContainer::iterator iterator;
iterator cur = c.begin();
const iterator last = c.end();
while ( (cur = std::find_if(cur, 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 AssociativeContainer, class Predicate>
inline void remove_if(AssociativeContainer& C, Predicate pred,
class associative_container_tag)
{
typedef typename AssociativeContainer::iterator iterator;
iterator cur = c.begin();
const iterator last = c.end();
while ( (cur = std::find_if(cur, last, pred)) != last)
{
iterator tmp = cur++;
c.erase(tmp);
}
}