|
From: Ioannis V. <no...@ho...> - 2002-08-19 23:18:38
|
> -----Original Message----- > From: Abhijit Shylanath [mailto:mu...@gm...] > Sent: Monday, August 19, 2002 11:24 PM > To: Ioannis Vranos; Dev-C++ Mailing List > Subject: Re: [Dev-C++] STL sort() problem > > > > > I tried doing > > > this: > > > > > > bool operator <(const PlsLine &left, const PlsLine &right) > > > > > > and the compile worked, but it doesn't seem to sort. > > > Any work-around? > > > > > > Yes, you probably made some logical error in the definition of > > operator<(). Send us its definition. > > > > The mistake was that the vector was still instantiated with > PlsLine *, not > with PlsLine. It's working now, thanks. Good. > Just for the record, > the other form > of sort() which takes a comparison function also works, as Eddy said. It is the same sort(). It uses < as default. If the default works do not use a comparison function or function object. The default is usually more optimised. Also try to make the operator<() inline (either a member function or a regular function). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |