Template bug?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jan 30 17:20:21 PST 2007


"Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message 
news:epnmuo$n9t$2 at digitaldaemon.com...

> static if + is-expressions (and creative 'alias' usage) clean that up 
> pretty well:
> -----
> struct temp_t( type ) {
>     static if(is(type == class))
>         alias type RefType;
>     else
>         alias type* RefType;
>
>     void setOwner( RefType newOwner ) {
>         owner = newOwner;
>     }
>
>     RefType getOwner() {
>         return owner;
>     }
>
>     protected {
>        temp_t *  head;
>        temp_t *  next;
>        temp_t *  prev;
>        RefType   owner;
>     }
> }

Ahh, I was thinking about static if but thought that doing it for each 
member would have been ugly.. never thought about using an aliased type. 




More information about the Digitalmars-d-learn mailing list