Re: Should this code compile?

From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 02/23/05


Date: Wed, 23 Feb 2005 20:31:29 +0100

BigMan wrote:

> Yes, the copy ctor DOES change the original - it transfers ownership of
> a resource that is too expensive to copy (e.g. a huge amount of
> memory).
> All this stuff about copy initilialization, direct initialization and
> the like seem to me rather silly... Most compilers will NOT call the
> copy ctor anyway in order to compile the above piece of code, so why
> should the standard require that the copy ctor be callable?!

Because the correctness of code doesn't depend on optimizations.

> This and other such requirements should be relaxed in order to make the
> language even more powerful!

And if it were, you might write code that needs the copy constructor on one
compiler an doesn't on another, i.e. your code would be unportable.



Relevant Pages

  • Re: Inadequate error message C2228
    ... Vladimir Grigoriev wrote: ... In 0, B) copy ctor could ... be omitted too (there is no sequence point after a whole ... It is interesting to note that different compilers behave differently. ...
    (microsoft.public.vc.language)
  • Re: Should this code compile?
    ... a resource that is too expensive to copy (e.g. a huge amount of ... memory). ... Most compilers will NOT call the ... copy ctor anyway in order to compile the above piece of code, ...
    (comp.lang.cpp)
  • Re: Inadequate error message C2228
    ... B) copy ctor could be omitted ... too (there is no sequence point after a whole expression), ... It is interesting to note that different compilers behave differently. ... Vladimir Grigoriev ...
    (microsoft.public.vc.language)