main.d(61): Error: temp_[i_] isn't mutable

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Sun Jun 20 12:14:24 PDT 2010


On Sun, 20 Jun 2010 12:01:31 +0000 (UTC), Ben Hanson 
<Ben.Hanson at tfbplc.co.uk> wrote:
> 
> == Quote from Justin Spahr-Summers (Justin.SpahrSummers at gmail.com)'s
> > "string" is actually an alias for "immutable(char)[]" (and
> similarly for
> > the other string types), so its contents are not modifiable, though
> its
> > length can be adjusted and contents appended. If you need to be
> able to
> > modify the characters, just use char[] instead. You can then use the
> > .idup property to get a string afterward.
> 
> I'm converted temp_ to CharT[] as suggested, but the conversion back
> to a string is failing:
> 
> _charset = temp_.idup;
> 
> main.d(76): Error: cannot implicitly convert expression (_adDupT((&
> D58TypeInfo_AT4main14__T5regexTAyaZ18basic_string_token5CharT6__initZ),cast
> (string)temp_)) of type immutable(CharT)[] to string

Sorry I missed this on the first run through. Since you're using typedef 
to create your CharT type, it will create a type independent from all 
the others, meaning no implicit casts to or from it. "alias" is the 
equivalent to a C/C++ "typedef", and that should fix the compilation 
error.


More information about the Digitalmars-d mailing list