I am unable to decide which STL container to use in the following case:
- I want to preserve the order of insertion of the elements
- The elements in the container have to be unique.
Is there any readymade container available for this? I don’t want to use a vector and then perform a std::find before doing a push_back every time.
Boost MultiIndexshould be able to do exactly what you want – you can just use one sequenced index to get the ‘ordered by insertion order’ requirement, and either ahashed_uniqueorordered_uniqueindex to get the uniqueness requirement.