Template alias parameter does not accept functions

Nick Treleaven ntrel-public at yahoo.co.uk
Wed Feb 27 09:38:45 PST 2013


On 27/02/2013 15:20, Dicebot wrote:
> Looking here: http://dlang.org/template.html#TemplateAliasParameter
>
> There are no function symbols in the list. And quick check that it won't
> compile.
>
> Two questions arise:
> a) Why so?
> b) Is there a workaround?

This has sometimes come up in the NG, with some support for the feature. 
See also:

http://d.puremagic.com/issues/show_bug.cgi?id=7308

bearophile shows the workaround - use another template:

template ID(alias a){alias a ID;}
void main(){
      alias ID!(x => x ^^ 2) sqrTemplate;
}

On 27/02/2013 17:17, Dicebot wrote:
 > Actually it looks like a somewhat broken behavior as it works for
 > parameter-less functions.

I'm not sure what you mean, can you show the code it works for?


More information about the Digitalmars-d-learn mailing list