Moving structs containing strings ...

Bob W nospam at aol.com
Mon Apr 24 03:19:43 PDT 2006


"Derek Parnell" <derek at psych.ward> wrote in message 
news:c7u4nwvom7ca$.o0vru71wqxwe.dlg at 40tude.net...
>
> Another solution is to recalculate the addresses of the id strings after
> changing the length ...
>
>  arr=arr[0..2];   // adjust length
>  foreach( inout Sc s; arr)
>      s.id = s.idz[0..s.id.length];
>

I'll gladly accept this as a solution, because it will
utilize existing strings within the structs-array.

The workaround you have posted earlier allocates
memory and duplicates strings one by one. That is
something I would not want to try in real-world
applications due to obvious reasons.

Thanks for your input.





More information about the Digitalmars-d-bugs mailing list