From: Michael Kenniston (Msk_at_[hidden])
Date: 2001-07-10 11:44:34
Ronald Garcia wrote:
> Peter Dimov writes:
> > "15.6. Keep in mind that the compiler will implicilty generate a copy
> > constructor, assignment operator and a destructor if you don't declare them
> > explicitly. If you rely on this behavior, document it using a comment inside
> > the class body:
> > // implicitly generated members are fine and useful
> > "
> I dont think one should have to state that the implicitly generated
> members are okay. I'd say that the absence of either
> boost::noncopyable or the private declaration of components would say
> enough. This comment seems to go against the grain of the language.
I disagree. The cost of including the comment is close to zero.
The cost of /not/ including it is the time (at least a minute, and possibly
much longer) that a programmer unfamiliar with the code has to spend
to decide if the omission of the ctor/assign/dtor was deliberate or accidental.
With a comment, the question is answered -- definitively -- in a second or two.
In other words, you are quite correct that the comment is not required to
specify the program's behavior, but given how easy it is to goof this up,
I think the comment is useful to specify whether that behavior is intentional.
-- - Michael Kenniston msk_at_[hidden] http://www.xnet.com/~msk/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk