"vertigo" <no**@none.pl> wrote in message
news:d0**********@nemesis.news.tpi.pl...
I have:
std::list<ObjPtr *> mylist;
i wanted to sort that pointers using my own sorting function:
mylist.sort(MySortingFunction);
I can't create that function, i receive many errors :( could anybody show
how sould it look like ?
As a function:
bool MySortingFunction(ObjPtr* a, ObjPtr* b)
{ return a->field < b->filed; }
-> mylist.sort( & MySortingFunction );
Note that using a function object might generate faster code
(on typical platforms) because it enables inlining of the
predicate.
You could start from something like:
struct MySorter {
bool operator()(ObjPtr* a, ObjPtr* b) const
{ return a->field < b->filed; }
};
-> mylist.sort( MySorter() );
I hope this helps,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form