Casting rules

JG someone at simewhere.com
Sat Aug 27 08:01:01 UTC 2022


On Friday, 26 August 2022 at 21:18:15 UTC, ag0aep6g wrote:
> On Friday, 26 August 2022 at 20:42:07 UTC, JG wrote:
>> [...]
>
> Casting immutable/const away: 
> https://dlang.org/spec/const3.html#removing_with_cast
>
> The cast itself allowed. Mutating the data is not.
>
> Casting to immutable: 
> https://dlang.org/spec/const3.html#creating_immutable_data
>
> The cast is allowed as long as you don't mutate the data 
> afterwards.
>
> Conversion to const doesn't need a cast. Mutable and immutable 
> both implicitly convert to const.


Thank you very much.


More information about the Digitalmars-d-learn mailing list