copy must be const?!?

swigy food hamza1r3g3h at gmail.com
Tue Jul 30 09:15:40 UTC 2024


Hello
A const copy ensures the copied value remains unchanged, 
providing safety and predictability. If the original is const, 
copying it as non-const could introduce unintended side effects. 
To modify a copied value, create a mutable copy explicitly.
For file systems, copying write-protected files maintains their 
attributes for security reasons. To modify them, change the file 
permissions after copying.
There isn't a direct way to tell the compiler to discard "const" 
or "immutable" attributes during a copy. You need to cast away 
constness explicitly where necessary.




More information about the Digitalmars-d-learn mailing list