Why does Unconst exist?

Ali Çehreli acehreli at yahoo.com
Wed Jul 28 05:52:02 UTC 2021


On 7/27/21 10:38 PM, Tejas wrote:
> When I initially saw it, I was hopeful that it would allow me to bypass 
> some of the restrictions of ```const``` , but it literally just takes a 
> type and strips the ```const``` from it, you can't pass a variable to it 
> in order to get rid of ```const``` . What use does it serve then?
> 
> https://dlang.org/library/std/traits/unconst.html

Searching under /usr/include/dmd reveals that it is used in the 
implementations of array property 'dup' and 'copyEmplace', which makes 
sense: We want copies to be mutable.

Ali


More information about the Digitalmars-d-learn mailing list