Hi, everyone!

I'm in search of an associative container that does not need an implementation of operator< for the key type. std::map and std::set requires that, so I think that I need another kind of associative container.

I can always implement my own contained using a vector of pairs, but I will lose the O(1) access of a key-value pair.

Can you help me?

7 Years
Discussion Span
Last Post by GDICommander

So what's the big deal about writing that operator overload ? I'm guessing those containers need that operator so that they can make binary searches. If the data is not ordered then they would have to resort to simple sequential linear searches.

Edited by Ancient Dragon: n/a


The key type is a template type provided by the client code. I don't want to force the client to implement an operator<, just for the std::map part of an algorithm.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.