Initializing an Immutable Field with Magic: The "Fake Placement New" Technique

FeepingCreature feepingcreature at gmail.com
Fri Jul 26 15:35:03 UTC 2019


On Friday, 26 July 2019 at 15:32:49 UTC, ag0aep6g wrote:
> As shown initially, if you don't mind relying on UB, you can 
> also just cast.

As *immediately answered*, no you *can't*. You can't write a 
generic function that assigns a new value to a pointer with cast, 
because the immutable may be on a field, and in any case the 
value may have assignment disabled.


More information about the Digitalmars-d mailing list