How do I find the largest int in a std::set<int>?

Viewed 44964

I have a std::set<int>, what's the proper way to find the largest int in this set?

6 Answers
if(!myset.empty())
    *myset.rend();
else
    //the set is empty

In an ordered integer set, the last element is the largest one.

Related