alias of member from pointer to struct?
BCS
ao at pathlink.com
Sat Apr 14 11:17:54 PDT 2007
Reply to Jarrett,
> "BCS" <ao at pathlink.com> wrote in message
> news:ce0a334393908c94bfc5c9037e4 at news.digitalmars.com...
>
>> should this work?
>>
>> struct S
>> {
>> int i;
>> }
>> S* s;
>>
>> alias s.i foo;
>>
> No. You cannot alias expressions.
>
is their a clean way to do this?
struct S
{
int i;
int j;
}
S* s;
static if(cond) alias s.i var;
else alias s.j var;
// use var for lots of things
This is going to be in a performance bottle neck so it must resolve to ideal
code.
Also this is supposed to be demonstrating D's ability to, along with other
things, remove redundancy so ideally only the actual symbol will appear in
the static if.
More information about the Digitalmars-d-learn
mailing list