digitalmars.D.bugs - [Issue 10890] New: To find all arguments of an instantiated template
- d-bugmail puremagic.com (29/29) Aug 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10890
- d-bugmail puremagic.com (17/17) Aug 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10890
- d-bugmail puremagic.com (12/12) Aug 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10890
http://d.puremagic.com/issues/show_bug.cgi?id=10890 Summary: To find all arguments of an instantiated template Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc Given an instantiated template like: struct Foo(T, U, size_t n) {} alias F1 = Foo!(int, float, 5); In many situations for me it's going to be useful a built-in trait (or a Phobos template with the same semantics) that returns a TypeTuple of the original template plus all the arguments used to instantiate it: __trait(templateArguments, F1) ==> TypeTuple!(Foo, int, float, 5) That means something like this should work: alias TT = __trait(templateArguments, F1); static assert(is(F1 == T[0]!(TT[1 .. $][]))); It should work with variadic templates too. I have tagged this as dmd enhancement, but if a full library implementation is possible, then this is meant just as a Phobos enhancement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 25 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10890 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh quickfur.ath.cx One workaround is to define a public alias inside your struct: struct Foo(T...) { alias TemplateArgs = T; ... } alias F1 = Foo!(int, float, 5); alias F1_parms = F1.TemplateArgs; It's not as pretty, but it works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 25 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10890 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich gmail.com Resolution| |DUPLICATE 15:57:08 PDT --- *** This issue has been marked as a duplicate of issue 4265 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 25 2013