[Issue 10890] New: To find all arguments of an instantiated template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 25 09:56:56 PDT 2013


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-08-25 09:56:55 PDT ---
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: -------


More information about the Digitalmars-d-bugs mailing list