I'm trying to figure out how to use the max_element algorithm on a vector of structs, rather than POD's like int etc.
This is my struct:
struct NameComponents
{
std::string sValue;
std::string sDescriptor;
int nOrder;
int nStatus;
// Construtor.
NameComponents( std::string inValue,
std::string inDescriptor,
int inOrder ) : sValue( inValue ),
sDescriptor( inDescriptor ),
nOrder( inOrder ),
nStatus( -1 ) { }
};
typedef std::vector < NameComponents > NameComponentContainer;
typedef NameComponentContainer::iterator NcIter;
typedef NameComponentContainer::const_iterator NcIterC;
NameComponentContainer m_nameComponents;
What I'd like to do is locate the max_element for member nOrder, any help appreciated.