Why does Unconst exist?

user1234 user1234 at 12.de
Wed Jul 28 05:57:31 UTC 2021


On Wednesday, 28 July 2021 at 05:38:44 UTC, 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?

To manipulate types in template metaprogramming.

To remove `const` from a variable, `cast() stuff` is shorter than 
`cast(Unconst!(typeof(stuff))) stuff`, but  it also removes 
`shared` and `immutable.


More information about the Digitalmars-d-learn mailing list