http://d.puremagic.com/issues/show_bug.cgi?id=5061
Summary: std.traits.arrayTarget Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: mcha...@gmail.com --- Comment #0 from Mike Chaten <mcha...@gmail.com> 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 functionality. 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------