Alias in templates

Don Clugston dac at nospam.com.au
Thu Dec 14 07:45:57 PST 2006


Peer Sommerlund wrote:
> Hi.
> 
> I'm trying to write a template for lists, using a slightly different approach
> than normal. I think I have not quite understood how alias works.
> 
> Could somebody please explain why the following gives compiler errors?

Because an alias parameter is passed as a fully-qualified name.
So in this case:
 > module foo;
 > class MyAdvanceNode {
 >   ListLink!(MyAdvanceNode,allocated) allocated;

'm' is not 'allocated', but rather 'foo.MyAdvanceNode.allocated'.
So 'n.m.next' is not going to make any sense.

You _might_ be able do this as a mixin instead, with a syntax something 
like:

class MyAdvanceNode {
mixin ListLink!(MyAdvanceNode) allocated;
}

-- but you'll have to develop a few new tricks, I think.


More information about the Digitalmars-d-learn mailing list