avoid extra variable during void pointer cast

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 14 15:03:01 PDT 2017


On Sunday, 14 May 2017 at 21:55:01 UTC, ag0aep6g wrote:
> On 05/14/2017 11:35 PM, Moritz Maxeiner wrote:
>> On Sunday, 14 May 2017 at 21:16:04 UTC, Stanislav Blinov wrote:
> [...]
>>> T* ptrCast(T, alias ptr)() { return cast(T*)ptr; }
> [...]
>>>     alias _state = ptrCast!(int, state);
> [...]
>> That's a pretty cool workaround, but not an alias to the cast, 
>> but an
>> alias to a parametrized function template (a type),
>
> Not sure if I'm reading that right, but `_state` is not an 
> alias of a (parametrized function) template.
>
> The template instantiation results in a function. `_state` is 
> an alias of that function. `alias foo = ptrCast;` would make an 
> alias of the template. Neither of them is a type.

You're right. I forgot about the alias to a symbol rule (event 
though I myself just linked to it :/ ). Sorry about that.


More information about the Digitalmars-d-learn mailing list