From: Craig Henderson (cdm.henderson_at_[hidden])
Date: 2002-11-18 14:16:42
"Dirk Gerrits" <dirk_at_[hidden]> wrote in message
> Craig Henderson wrote:
> > Hi,
> > I am deriving from boost::noncopyable to prevent copying of my
> > objects. When I compile in VC7 with /W4 (warning level 4), I get a
> > warning C4511 - copy constructor could not be generated
> Isn't that what boost::noncopyable is supposed to do?
In an ideal world, I wouldn't expect a warning or error unless I actually
tried to copy the object.
> > The documentation states that: "This warning can be caused by having a
> > copy constructor for the base class that is not accessible by the
> > derived class". As a result, I changed the copy ctor and assignment
> > operator to be protected rather than private to make them visible to
> > the derived class, and all is well.
> Won't this mean that inside the class, copying will cause a link-time
> failure, and outside of it a compile-time failure? The mistake of
> accidentally copying an instance inside the class itself is probably
> pretty rare, but still, catching errors as early as possible is
> preferable IMHO.
I guess so, but I would prefer to take this minor disadvantage in return for
a clean compile at warning level 4.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk