-4

Which standard C++ collections include built in remove/remove_if operations?

For example, I see that list has them:

http://www.cplusplus.com/reference/list/list/remove/ http://www.cplusplus.com/reference/list/list/remove_if/

list<int> mylist (...);
mylist.remove(42);

but vector does not, and I have to do v.erase(remove(etc.etc.etc.))

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
  • 2
    You could always [look at the docs](http://en.cppreference.com/w/cpp) for each of the containers. I gotta ask....why haven't you done this already? – Captain Obvlious Feb 15 '17 at 20:53
  • 1
    Chances are the container types reported by a [search of the docs](http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=remove) would be a pretty good indicator of which containers have this, and which do not. That list culls down *considerably* if you [search on `remove_if`](http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=remove_if). – WhozCraig Feb 15 '17 at 21:05
  • @Jay Bazuzi I saw it in `algorithm' also, http://www.cplusplus.com/reference/algorithm/remove/ – Dineshkumar Feb 15 '17 at 21:11
  • Related topic: [Why does vector not have sort() method as a member function of vector, while list does?](http://stackoverflow.com/questions/4342957/why-does-vector-not-have-sort-method-as-a-member-function-of-vector-while-lis) – user4581301 Feb 15 '17 at 21:32
  • I'm looking for a canonical list, and did a Google search, but didn't find one. I can read the docs myself, but I'm not sure if I'll miss any important, subtle details. – Jay Bazuzi Feb 15 '17 at 21:32
  • @Dinesh - That's the non-built-in remove, which can be applied anywhere you have iterators. – Jay Bazuzi Feb 15 '17 at 21:37
  • If you want a canonical list why not look at the standard? It tells you all of the member functions that need to be implemented. – Captain Obvlious Feb 15 '17 at 23:05

1 Answers1

0

At the bottom of http://en.cppreference.com/w/cpp/container I see a table listing all the operations on all the STL containers, and remove/remove_if only appear on forward_list and list.

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168