Joe Buck wrote:
On Mon, Mar 02, 2009 at 12:16:42PM -0800, Mark Mitchell wrote:
The C++ standard limits the compiler's ability to introduce copies.  It
says "Here are where copies occur; some of these can be optimized away."
 It doesn't say anything about inserting more copies.  So, depending on
exactly how this works, it might or might not be technically
standard-conforming to introduce copies at this point.

On the other hand, the committee long ago endorsed the concept that
a copy constructor can be treated as simply making copies in some
contexts (e.g. named return value optimization), so to the extent
that this extends this, it is philosophically consistent (meaning
that eventually a future committee might well bless it).
That could reasonably happen. However, not all objects can be copied.
For example auto_ptr<T> does not have a (const) copy constructor.
Sometimes it is too difficult to write a good copy constructor with a reasonable
semantics and/or reasonable performance. In that case people block copy
constructors:

   |class no_copy {|
   |private:|
   | no_copy(const no_copy&);|
   | no_copy& operator=(no_copy)|
   |};|
   ||
   class a_complex_class : private no_copy {
   ....
   };

In this case, how is it possible to copy the objects? Will things just crash at run-time?

Michael

Reply via email to