Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
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

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote: Please show an example of .dup you'd like to avoid. For example, if you need to create a five-dimensional array of strings :)

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote: 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. Yes. That's right, and not otherwise :)

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 17:02:06 UTC, Dennis Ritchie wrote: On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote: [...] 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 =

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Kagamin via Digitalmars-d-learn
Type is probably possible, though conversion method will be simpler. You can even try to write a specialization of `to` for multidimentional arrays if it doesn't work.

char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
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 :) I

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
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]; I suggest that such an option: str[] strArray =

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote: 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. Yes, string literals. I understand that the type of `string[]` to D is a simple data

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
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,

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 16:09:58 UTC, Dennis Ritchie wrote: On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote: [...] 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

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote: I wish to propose the creation of new types of data D: str, wstr, dstr, which will be the analogs of C++ `std::vectorstd::string`. Ie str, wstr, dstr be mutable counterparts immutable strings respectively str (mutable(char[])),

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 18:15:30 UTC, Dennis Ritchie wrote: Actually, I will file issue `std.conv` in Phobos to add such specifications. It will suit me. *specializations

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 17:39:25 UTC, Kagamin wrote: Type is probably possible, though conversion method will be simpler. You can even try to write a specialization of `to` for multidimentional arrays if it doesn't work. It appears the problem can be solved by creating specifications

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 13 June 2015 at 17:37:31 UTC, anonymous wrote: Please show how it is not. Seems to work just fine. OK. Still, this method works: char[][][][][][] strArr = [foo, baz], [bar, tor.to!(char[][][][][])]; But I don't want to write this `.to!(char[][][][][])`. On Saturday,