Hello
I have a ptr_container:
In container I store derived objects from base.Code:ptr_vector<base> container;
Derived2 class has an int member and I'd like to sort elements in container by the highest number.Code:class derived1 : public base { }; class derived2 : public base { public: int number; };
I know if I had normal container I could do:
But how can I do it in this case? What is the best way? I dont want to get things too complicated if not neccessary.Code:std::sort(container.begin(), container.end(), tr1::bind( .. etc..
Note that classes contain enum so I know which type they are (so I can do static_cast) and only derived2 should be sorted in container. There could be also derived or derived3 objects in a container.
Any help is highly appreciated