Summary: std.traits.arrayTarget
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from Mike Chaten <> 2010-10-15 21:44:45 PDT ---
I've been in need of getting the type of the contents of an array. Phobos
includes a function to get the type of the pointer target.

I propose a simple template, arrayTarget to std.traits to implement this

The following works under DMD 2.049, Linux/x86

template arrayTarget(T:T[]) {
        alias T arrayTarget;
unittest {
        assert(is(arrayTarget!(int[5][]) == int[5]));
        assert(is(arrayTarget!(int[5]) == int));
        assert(is(arrayTarget!(int[]) == int));
        assert(is(arrayTarget!(int[][]) == int[]));
        assert(__traits(compiles,arrayTarget!(int)) == false);
        assert(__traits(compiles,arrayTarget!(int *)) == false);

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to