[try Beta version]
Not logged in

 
Custom Class for std::set

Oct 27, 2014 at 2:14am
When we want to use custom classes for the STL set data structure, which way do you guys do it?

I look around and see people passing comparators, overloading operator(), and also overloading operator< in the class itself.

Which one's the idiomatic c++ way?
Oct 27, 2014 at 4:09am
They are all idiomatic, this is more of a question of class design.

If a class has an ordering relation that makes sense for its values, provide operator<

When it doesn't (or perhaps when it has multiple ways in which it can be ordered), then create a comparison predicate.
Topic archived. No new replies allowed.