www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5061] New: std.traits.arrayTarget

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: mchaten gmail.com


--- Comment #0 from Mike Chaten <mchaten 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: -------
Oct 15 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com


--- Comment #1 from yebblies <yebblies gmail.com> 2011-06-15 23:16:49 PDT ---
Is this covered by ElementType/EncodingType?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-18
13:19:11 PST ---
(In reply to comment #1)
 Is this covered by ElementType/EncodingType?
Yes, except it's more generic and works with pointers too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |verylonglogin.reg gmail.com
         Resolution|FIXED                       |


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-02-18
10:30:43 MSK ---
Not fixed.
The enhancement is about arrays, not ranges. Phobos misses a lot of traits in
regard to arrays. This one included.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #4 from yebblies <yebblies gmail.com> 2013-02-18 18:49:27 EST ---
Arrays _are_ ranges.  This functionality is already in phobos.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061



--- Comment #5 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-02-18
13:42:03 MSK ---
(In reply to comment #4)
 Arrays _are_ ranges.
No. E.g. `int[1]` and `const int[]` are not ranges.
 This functionality is already in phobos.
`char[]` can be just an array of `char`-s without any thoughts about encoding and combining that `char`-s into a string so neither `ElementType` nor `ElementEncodingType` are applicable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-18
09:17:34 PST ---
(In reply to comment #5)
 (In reply to comment #4)
 Arrays _are_ ranges.
No. E.g. `int[1]` and `const int[]` are not ranges.
Both ElementType and ElementEncodingType work with these.
 `char[]` can be just an array of `char`-s without any thoughts about encoding
 and combining that `char`-s into a string so neither `ElementType` nor
 `ElementEncodingType` are applicable.
I don't understand what you mean. A code example would help. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5061


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WONTFIX


--- Comment #7 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-10-26
12:11:57 MSD ---
The fix was in phobos pull 776 [1] which was rejected. Andrei's comment [2]:

 I appreciate the arguments in favor of adding an ArrayElementType. However,
ElementEncodingType is adequate (albeit unintuitively named) and I couldn't get
convinced by the arguments involving precedents. I will close this now. Thanks
for the contribution, and let's focus on the more meaty ones.
[1] https://github.com/D-Programming-Language/phobos/pull/776 [2] https://github.com/D-Programming-Language/phobos/pull/776#issuecomment-8603386 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 26 2013