Is there something special required to use Appender.clear
FeepingCreature
feepingcreature at gmail.com
Thu Jan 24 12:35:43 UTC 2019
On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote:
> On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote:
>> Sorry if this is a stupid question, but is there something
>> special required to call Appender.clear? When I attempt even
>> just a simple use I am getting compile errors relating to
>> `template object.clear`.
>
> From the documentation for Appender:
>
>> Note
>> clear is disabled for immutable or const element types, due to
>> the possibility that Appender might overwrite immutable data.
>
> Since string is immutable(char)[], clear() is simply not
> available for appender!string.
>
> --
> Simen
Isn't this wrong, though? Appender controls the memory it
references. It could just choose to allocate non-immutable memory
internally. As long as any const data put into the appender is
*returned* as const, there is no chance of immutable memory being
overwritten.
More information about the Digitalmars-d-learn
mailing list