Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Special case of remove_if (C++)

Name: Anonymous 2009-11-02 12:54

Sup /prog/, I'm asking for a bit of help.

So I got a std::vector<std::pair<typeA , typeA>>, and I want to remove all pairs containing some typeA value 'x'.

(How) can I do this in a easy, elegant way?

I've thought about using the STL algorithm remove_if, but looking at this reference:

http://www.cplusplus.com/reference/algorithm/remove_if/

template < class ForwardIterator, class Predicate >

ForwardIterator remove_if ( ForwardIterator first, ForwardIterator last, Predicate pred )

pred
    Unary predicate taking an element in the range as argument, and returning a value indicating the falsehood (with false, or a zero value) or truth (true, or non-zero) of some condition applied to it. This can either be a pointer to a function or an object whose class overloads operator().

Seems like remove_if can't do the trick then, eh? It has to have the pair object and the reference value 'x'.

This is a c++ problem, if I didn't make it clear enough before.

Name: Anonymous 2009-11-02 13:12

(remove x sequence)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List