December 22, 2007
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?
December 23, 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