digitalmars.D.bugs - [Issue 12411] New: New eponymous template syntax could support nested eponymous templates
- d-bugmail puremagic.com (61/61) Mar 19 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12411
https://d.puremagic.com/issues/show_bug.cgi?id=12411 Summary: New eponymous template syntax could support nested eponymous templates Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 01:42:34 PDT --- Example code: ----- import std.typetuple; enum canAppend(R) = anySatisfy!(canAppendRange!R, Types); private alias Types = TypeTuple!(int, float); // problem: can't use new-style eponymous syntax for nexted templates private template canAppendRange(R) { enum canAppendRange(T) = is(typeof({ R r = void; T t = void; r ~= t; })); } void main() { static assert(canAppend!(int[])); static assert(canAppend!(float[])); static assert(!canAppend!(byte[])); } ----- Notice how 'canAppendRange' has to use the old-style eponymous syntax in order for it to be usable with partial instantiation in the call to anySatisfy. Perhaps a somewhat reasonable enhancement would be to allow nested eponymous syntax: ----- enum canAppendRange(R)(T) = is(typeof({ R r = void; T t = void; r ~= t; })); ----- A simplified example test-case: ----- // old-style template isEqual(T1) { template isEqual(T2) { enum bool isEqual = is(T1 == T2); } } // new-style enum isEqual(T1)(T2) = is(T1 == T2); void main() { alias isInt = isEqual!int; static assert(isInt!int); } ----- The whole idea is to allow new syntax to allow easier writing of templates which can be partially instantiated. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 19 2014