Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find minimum

41 views
Skip to first unread message

Christopher Pisz

unread,
Jan 23, 2015, 7:16:33 PM1/23/15
to
I need to get the element of a vector that returns the smallest value
when one of its member functions is called.

Suppose I have

struct Person
{
typedef std::shared_ptr<Person> Shared_Ptr;
int m_height;
}


How do I get the shortest person from
std::vector<Person::Shared_Ptr>

without looping through it myself?

Is there an std::algorithm and how would I write the predicate? Or do I
sort and use a predicate?

red floyd

unread,
Jan 23, 2015, 7:52:13 PM1/23/15
to
std::min_element has a form that takes a comparator.

0 new messages