Remaining const niggles #1 - Custom POD types
Walter Bright
newshound1 at digitalmars.com
Mon Feb 18 14:04:07 PST 2008
Janice Caron wrote:
> The problem is that the
> following /doesn't/ work (as in, won't compile!)
>
> typedef char mychar;
> alias invariant(mychar)[] mystring;
>
> mystring s = cast(mystring)"hello";
> mychar c = s[0];
That's a bug and will get fixed on the next update. The rule is that a
typedef can be implicitly converted to/from invariant if the underlying
type can be.
Structs will be implicitly convertible to/from invariant if each of its
fields can be (even private fields).
More information about the Digitalmars-d
mailing list