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

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


On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote:
> Hello, everyone!
>
> I like to work with arrays of strings like `string[] strArray`, 
> but unfortunately, they are immutable.
>
> I do not like to work with arrays of strings such as `char[][] 
> strArray`, because it is necessary to apply the method .dup 
> each substring to make them work :)

Huh? You mean with string literals? That would be a rather silly 
reason to avoid `char[]`. Please show an example of .dup you'd 
like to avoid.

> I understand that the type of `string[]` to D is a simple data 
> type than `char[][]`,

Are you saying that `string[]` is simpler than `char[][]`? That's 
not true: `string` is an alias for `immutable(char)[]`, so 
`string[]` is the same as `immutable(char)[][]`.

> but it seems to me that the problem is solved in C++:
> std::vector<std::string> stdArray;
>
> I wish to propose the creation of new types of data D: str, 
> wstr, dstr, which will be the analogs of C++ 
> `std::vector<std::string>`.

Before jumping to a solution, please elaborate on the perceived 
problem. I have a feeling that there is none.



More information about the Digitalmars-d-learn mailing list