Parameterized enum does not work

Andre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 8 22:17:52 PST 2015


Hi,

Should following coding work?

string lpad(ubyte length, long n)
{
	import std.string: rightJustify;
	import std.conv: to;
	return rightJustify(to!string(n), length, '0');
}
	
enum lpad14(long n) = lpad(14, n);

void main()
{
	lpad14(123);
}

There is following error from dmd:

source\app.d(12): Error: template app.lpad14 cannot deduce 
function from argumen
t types !()(int), candidates are:
source\app.d(8):        app.lpad14(long n)

Kind regards
André


More information about the Digitalmars-d-learn mailing list