Template alias parameter does not accept functions

Nick Treleaven ntrel-public at yahoo.co.uk
Wed Feb 27 10:21:29 PST 2013


On 27/02/2013 18:06, Dicebot wrote:
> Ye, lambda litteral issue is different one.

OK.

> My code example: http://dpaste.1azy.net/b06370ea

The problem may be related to optional parentheses and stringof, and may 
be a compiler bug.

You can pass function names as a template alias parameter:

import std.stdio;

int f(int i) {return i^^2;}

template check(alias Symbol)
{
	enum check = Symbol(5); // CTFE
}

void main()
{
     //~ pragma(msg, f.stringof); //error

     writeln(check!f); // 25
}


More information about the Digitalmars-d-learn mailing list