Bug 4821 – std.array.insert on string[]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-09-05T09:14:00Z
Last change time
2012-09-30T16:07:49Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-09-05T09:14:13Z
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.)
Comment #1 by dmitry.olsh — 2012-09-28T09:11:36Z
insert probably got deprecated with time. But this code works for me: import std.array: insertInPlace; void main() { string[] a; a.insertInPlace(0, "hello"); }