template with enum arg ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 8 10:02:14 PDT 2016


In a first implementation I defined a named enum in my class 
which I could use with my template function foo.

----
final class Info {
     ...
     enum Value { info_1 = 1, ... }
     ...
     static bar(Value e) {...}
}

void foo(T)(T.Value e) { T.bar(e); }

----

I could then write : foo(Info.Value.info_1);

I would prefer to write : foo(Info.info_1);

If I change the enum into an anonymous enum the template doesn't 
work anymore.

How could I solve this ?

Also, do I need a template argument filter if() ?



More information about the Digitalmars-d-learn mailing list