template ref parameter

bearophile bearophileHUGS at lycos.com
Wed Nov 21 04:05:22 PST 2012


Jack Applegame:

A brony? :-)

> But sometimes ref becomes a part of type. For example "void 
> delegate(ref int)" and "void delegate(int)" are different 
> types. Is it possible to cast from one to another safely? For 
> example:
>
> void foo(ref int);
> void function(int) fp;
> fp = cast(typeof(fp)) foo; /// is it safe???

In one case the function expects a pointer and in one case it 
expects a int value. The assembly code of the two functions is 
different and does different things.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list