mercredi 15 juin 2016

Search for value in multi map


Suppose I have the following:

class Foo {
public:
    Foo(int x) {
        _x = x;
    }
    int _x;    
}

int main() {
    multimap<string, Foo> mm;
    Foo first_foo(5);
    Foo second_foo(10);

    mm.insert(pair<string, Foo>("A", first_foo));
    mm.insert(pair<string, Foo>("A", second_foo));

    Foo third_foo(10); 
}

What's a nice way of checking if third_foo with key "A" is already in my multimap?


Aucun commentaire:

Enregistrer un commentaire