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.

Yep, it's an alias to template function instantiation, that is, concrete function - a symbol.

But of course, it *is* going to be called on every "dereference". GDC optimizes the call away starting at -O1, LDC needs -O2. DMD makes temporaries :)

Reply via email to