From: Fredrik Blomqvist (fredrik_blomqvist_at_[hidden])
Date: 2005-04-19 17:53:54
Pavel Chikulaev wrote:
> "Fredrik Blomqvist" <fredrik_blomqvist_at_[hidden]> wrote in message
>> I can't find any code or docs dealing with comparison in the current
>> CVS. Weren't ptr_container supposed to have deep comparison
> Even if it had, you should make sure that your classes have properly
> implemented comparison operators.
Yes of course, but they still wont be used unless the container fwds to
> Otherwise only base class's parts
> will be compared, and since such behaviour is undesirable and most
> users don't need any comparison operators or simply won't write them
> or will write them polymorphically incorrect,
hmm, yes, I can see how it could be fairly error prone..
> Thorsten, I guess, decided not to have comparison operators at all.
My post was trigged by a note in the docs(?) suggesting they were supposed
to be added. But now I can't seem to find a link to it again...
(perhaps Thorsten updated some docs very recently?)
> For proper comparison you should ensure that you comparing objects of
> the same dynamic type, then compare all base parts, the derived one.
> Because of this, it's just not possible to write comparison operators
> for ptr_container with every type you put in it.
Couldn't the lib assume/trust them to be polymorphic in that case?
(and as correct as such implementation allows)
> BTW, you can always write our own comparison operators for
> ptr_containers of your classes if you really need them.
Yes. Perhaps they could simply be put in a separate header to be pulled in
// Fredrik Blomqvist
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk