alias of member from pointer to struct?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Apr 14 17:04:01 PDT 2007


"BCS" <ao at pathlink.com> wrote in message 
news:ce0a334394148c94cbf4314a4da at news.digitalmars.com...
> Reply to Jarrett,
>
>> If the static if is not at global scope, you can make a variable that
>> points to the member:
>>
>> const bool pick = false;
>>
>> struct S
>> {
>> int i;
>> int j;
>> }
>> void main()
>> {
>> S* s;
>> static if(pick)
>> int* var = &s.i;
>> else
>> int* var = &s.j;
>> }
>
>
> That's what I'm trying to avoid. :(
>
>

If you want to avoid the address calculation every time you write "s.i" or 
"s.j", that's what you'll have to do.  Even a macro that expanded to "s.i" 
or "s.j" would not give you any performance gain. 




More information about the Digitalmars-d-learn mailing list