I asked this question earlier. I am intrigued by std::set but I have another confusing scenario.
Namely, is the following code legal, portable c++ for T=std::vector and T=std::set:
template <typename T>
void remove_elements(T& collection, int removal_value)
{
typename T::iterator new_end =
std::remove(collection.begin(), collection.end(), removal_value);
collection.erase(new_end, collection.end());
}
According to the SGI reference, set::iterator and set::const_iterator are the same, so I don't know if this is legit. However, I can't seem to find another way to get the operation I need to work regardless of type. I could resort to template specialization, however it would be nice not to have to specialize in the first place.