|
Boost : |
From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-11 02:28:16
On Sat, Oct 11, 2003 at 04:54:21PM +1000, Thorsten Ottosen wrote:
> I'm playing a little with some pointer containers and would like some
> iterators s.t
>
> class Base;
> bool operator<( const Base& r, const Base& l );
This may be your flaw right here.
Usually people want to be able to compare Dogs with Dogs and Cats with
Cats, but not Dogs with Cats. However if you define a less-than
operator like that, you have to be able to compare any two Animals.
If this is really what you intend to do (perhaps it is), then I think
you shouldn't have any problems implementing what you're trying to
implement.
But if instead, you only want to be able to compare Dogs to Dogs and
Cats to Cats, then the whole idea of sorting a ptr_vector<Animal*> is
flawed. You can't sort a container when the elements aren't necessarily
comparable to one another.
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk