www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4821] New: std.array.insert on string[]

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4821

           Summary: std.array.insert on string[]
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-09-05 09:14:13 PDT ---
This D2 program correctly inserts the int 10 at the first position of an empty
array (dmd 2.048):

import std.array: insert;
void main() {
    int[] a;
    a.insert(0, 10);
    assert(a == [10]);
}



But a similar program doesn't work with an array of strings:


import std.array: insert;
void main() {
    string[] a;
    a.insert(0, "hello");
}


Errors:
...\dmd\src\phobos\std\array.d(518): Error: cannot implicitly convert
expression (e) of type immutable(char) to string
...\dmd\src\phobos\std\array.d(14): Error: template instance
std.array.insert!(string,string) error instantiating

(A related necessary function std.array.remove is missing.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4821


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com


--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-09-28
09:11:36 PDT ---
insert probably got deprecated with time. But this code works for me:

import std.array: insertInPlace;

void main() {
    string[] a;
    a.insertInPlace(0, "hello");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 28 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4821


bearophile_hugs eml.cc changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2012