type of concatenated arrays
Janice Caron
caron800 at googlemail.com
Wed Nov 7 13:52:36 PST 2007
On 11/7/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> Now, a2 is declared as a const(char)[] array, but I think it should be just
> a char[] array. Why? because the concat operator should have made a copy
> of the array with length +1 and added the \n character. If this is the
> case, I should be able to do whatever I want with the copy. Why does it
> have to be const?
Because of copy-on-write.
If b is the empty string, then (a ~ b) will evaluate to a. No copy need be made.
More information about the Digitalmars-d
mailing list