Inability to dup/~ for const arrays of class objects
Steven Schveighoffer
schveiguy at yahoo.com
Tue May 28 06:41:07 PDT 2013
On Sat, 25 May 2013 23:58:39 -0400, Peter Williams
<pwil3058 at bigpond.net.au> wrote:
> Is the inability to use dup and ~ with const arrays of class objects a
> deliberate design restriction? I couldn't find mention of it in the
> specification or Andrei's book and only discovered it the hard way.
It has to be. There is no cdup.
For any const(T)[] x, the type of x.dup is T[]. Because this would mean
that you would remove const, you cannot do that. Nor can you idup, since
implicit conversion to immutable is not possible.
As far as I know, ~ works with const arrays of class objects. Can you
give a case where it fails?
-Steve
More information about the Digitalmars-d
mailing list