inout and function/delegate parameters
Timon Gehr
timon.gehr at gmx.ch
Wed Mar 7 16:06:14 PST 2012
On 03/07/2012 11:37 PM, Stewart Gordon wrote:
> On 07/03/2012 15:41, Steven Schveighoffer wrote:
> <snip>
>> In fact, I think this is valid D code:
>>
>> int i;
>> const int *pi = &i;
>> int *p = cast()pi;
>> *p = 5; // legal because I know this points at i, and i is really mutable
>
> cast() is an abomination. I'm not sure OTTOMH whether it's a bug that it
> works.
>
It is not legal code. I did not point it out because it was clear what
was meant. cast() only casts away the top level of modifiers. It is
perfectly safe except for class objects.
More information about the Digitalmars-d
mailing list