char[][] to std::vector<std::string> - DIP or dmd-issue?

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 13 09:20:45 PDT 2015


On Saturday, 13 June 2015 at 15:58:44 UTC, Dennis Ritchie wrote:
> On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
>> Before jumping to a solution, please elaborate on the 
>> perceived problem. I have a feeling that there is none.
>
> Do you like to write?
> char[][] strArray = ["foo".dup, "bar".dup, "baz".dup];

Ok. That's all you're on about? Basically you'd like this:
     char[] s = "foo";
and this:
     char[][] a = [["foo"]];
etc.

Yeah, that would be neat. But typing out ".dup" isn't that bad, 
and converting a `string[]` to a `char[][]` is simple:
     import std.conv: to;
auto a = ["foo"].to!(char[][]);

> I suggest that such an option:
> str[] strArray = ["foo", "bar", "baz"];

I don't see how adding a new builtin type `str` would solve 
anything.



More information about the Digitalmars-d-learn mailing list