digitalmars.D.learn - How do I create a char[] from a const(char)[]?
- Dan (7/7) Dec 22 2007 I have a const(char)[] string being passed in as a parameter (can't chan...
- Derek Parnell (8/18) Dec 22 2007 I just use ...
I have a const(char)[] string being passed in as a parameter (can't change that) and I want to create a duplicate that is not const. I tried all manner of things that would make sense to dispose of the constness of it. It's looking though that I will have to actually loop through and cast every freaking character? void myfunc(const(char)[] sin){ char[] sout = cast(char[]) sin; // nope char[] sout = cast(char[]) sin.dup; // nope char[] sout = (cast(char[]) sin).dup; // nope What's the trick?
Dec 22 2007
On Sat, 22 Dec 2007 18:35:26 -0500, Dan wrote:I have a const(char)[] string being passed in as a parameter (can't change that) and I want to create a duplicate that is not const. I tried all manner of things that would make sense to dispose of the constness of it. It's looking though that I will have to actually loop through and cast every freaking character? void myfunc(const(char)[] sin){ char[] sout = cast(char[]) sin; // nope char[] sout = cast(char[]) sin.dup; // nope char[] sout = (cast(char[]) sin).dup; // nope What's the trick?I just use ... char[] sout = sin.dup; What version of D are you trying this with? -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Dec 22 2007