Non-immutable char[] doesn't change?

Timon Gehr timon.gehr at gmx.ch
Sat Aug 18 05:41:52 PDT 2012


On 08/18/2012 02:15 PM, Salih Dincer wrote:
> This may be the solution...:)
>
> char[] b = cast(char[])"abc".dup; // ok, unique reference
>
> Sorry...

You don't need the cast in this case.

Topic: It is not a bug, but it might be surprising because the
behaviour of typeid is different with polymorphic types.

Typeid on a class object gives you back the RTTI structure of the
value's type, while typeid on anything else gives you back the RTTI
of the statically determined variable type.

The reason this works this way is because class objects are the only
objects which actually carry runtime type information with them.


More information about the Digitalmars-d-learn mailing list