Aliases
BCS
BCS at pathlink.com
Mon Oct 23 09:34:37 PDT 2006
All of the below add members or variables to whatever they are in. The
alias solution is 100% compile time, and has no effect on the structure
layout.
Walter Bright wrote:
> Reiner Pope wrote:
>
>> int[2] nodes;
>> alias nodes[0] left;
>> alias nodes[1] right;
>
>
> How about:
>
> auto left = &nodes[0];
> auto right = &nodes[1];
>
> Or:
>
> auto left = (){ return nodes[0]; }
> auto right = (){ return nodes[1]; }
>
>> class Foo
>> {
>> void DoSomething() {...}
>> }
>>
>> class FooHandle
>> {
>> Foo myFoo;
>> alias myFoo.DoSomething DoSomething;
>> }
>
>
> Or:
> auto DoSomething = &myFoo.DoSomething;
>
This one might be non-doable with the alias as it will almost certainly
requirer some translation code.
More information about the Digitalmars-d
mailing list