From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-03-09 01:35:16
"Alberto Barbati" <abarbati_at_[hidden]> wrote in message
> Thorsten Ottosen wrote:
> > yeah, I could have said it better :-) What I meant was that
> > ususally
> > incompatible with non-trivial destructors. What I mean by non-trivial
> > destructors is that
> > eg. a file is closed or a connection is closed. In those cases making
> > temporaries and copies
> > is not good:
> I learned that good programming practice is that if a class requires a
> non-trivial destructor it should either implement both the copy
> constructor and the assignment operator or declare them private and
> leave them unimplemented.
true. Don't be confusd by my slight misuse of "non-trivial destructor".
>Moreover, if either the copy constructor or
> the assignment operator is defined, both of them should.
>I never found a
> case where it was worth violating this practice, maybe you have such an
> Fact is that I still fail to understand why a class that has a
> meaningful copy constructor cannot implement a meaningful assignment
> operator with the same semantic as dtor+copy ctor, but more efficiently.
I can't either.
[remark: we agree that circular_buffer should use assignment]
[note:I was trying to mention a specific type of RAII objects which cannot
be put in copying containers].Copy behavior is not always desireable.
If assigment of a Socket class would require the connection to close(), then
I don't want assigment. And I don't want temporary objects. Hence the object
must be heap-allocated.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk