Boost logo

Boost :

From: Dirk Gerrits (dirk_at_[hidden])
Date: 2002-11-18 07:35:00


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?

> 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.

Dirk Gerrits


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk