Invariant Question (yes, another one)
Reiner Pope
some at address.com
Thu Nov 15 15:41:13 PST 2007
Janice Caron wrote:
> On 11/15/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>> Your first data type is an AA with invariant strings as keys and values.
>> HOWEVER, the AA itself is not invariant. Suppose after you converted to an
>> AA with const strings as keys and values, you replaced one of the values
>> with a mutable string cast into a const string.
>
> Yes, you're right.
>
> invariant(char)[][] won't implicitly convert to const(char)[][]
> either, for the same reason.
> But...
> invariant(char[])[] will implicitly conver to const(char[])[]
>
> But here's the odd thing...
>
> invariant(char[])[] will implicitly conver to const(char[])[]
> but
> invariant(char[])[int] won't implicitly convert to const(char[])[int]
>
> The only difference is the int in the square brackets.
I think it's just the odd behaviour that invariant(char[])[] is actually
the same as invariant(char[][]), which is implicitly convertible to
const(char[][]), the same as const(char[])[].
-- Reiner
More information about the Digitalmars-d
mailing list