jeudi 18 avril 2019

How to get a single item from an unordered_set?

I can do:

std::unordered_set<MyThing*> things;
MyThing aThing = nullptr; 
for(auto item : mySet){
    aThing = item;
    break;
}

Is there a way to get a single item without having to write all this code to iterate ?

I want to know simply out of curiosity.

Aucun commentaire:

Enregistrer un commentaire