alias of member from pointer to struct?
Jarrett Billingsley
kb3ctd2 at yahoo.com
Mon Apr 16 17:10:18 PDT 2007
"BCS" <BCS at pathlink.com> wrote in message
news:f00649$j6f$2 at digitalmars.com...
>
> struct S
> {
> int i;
> int j;
>
> int go(bool pick)(S* bar)
> {
> static if (pick)
> {
> alias i foo;
> alias bar.j baz;
> }
> else
> {
> alias j foo;
> alias bar.i baz;
> }
> return foo % baz;
> }
>
> alias go!(true) go1;
> alias go!(false) go2;
> }
>
> It's not an exact example, but shows the problem
I should hope that in reality the body of go() is long enough to even
warrant the use of such an alias. Otherwise:
int go(bool pick)(S* bar)
{
static if (pick)
return i % bar.j;
else
return j % bar.i;
}
More information about the Digitalmars-d-learn
mailing list