avoid extra variable during void pointer cast

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 14 14:55:01 PDT 2017


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.


More information about the Digitalmars-d-learn mailing list