Why can't structs be derived from?

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Mar 15 17:02:24 PDT 2011


On 3/16/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> On Tuesday, March 15, 2011 15:34:50 Andrej Mitrovic wrote:
>> Speaking of structs, shouldn't it be possible to write this:?
>>
>> struct AAWrapper(KeyType, ValType)
>> {
>>     ValType[][KeyType] payload;
>>     alias payload.opIndex opIndex;
>> }
>>
>> The reasoning behind this is that opIndex in AAWrapper really just
>> forwards to payload's opIndex, while other functions like
>> opIndexAssign would be specialized in AAWrapper. This currently does
>> not compile though.
>
> Does the built in AA even really have an opIndex as far as the compiler is
> concerned? It would have to have that exact name for that to work, I
> believe.
>
> - Jonathan M Davis
>

It looks like its hidden from the user. From what I can tell what's
exposed to the user is AssociativeArray!() from object_.d, and there's
no opIndex there. Oh well. :)


More information about the Digitalmars-d mailing list