What is this strange alias syntax?
Timon Gehr
timon.gehr at gmx.ch
Mon May 23 11:06:31 PDT 2011
Steven Schveighoffer wrote:
> On Mon, 23 May 2011 10:50:11 -0400, Andrej Mitrovic
> <andrej.mitrovich at gmail.com> wrote:
>
>> Since &main can't be a template value argument, maybe he meant this use
>> case:
>>
>> alias int func();
>>
>> void foo(alias T)()
>> {
> static assert(is(typeof(&T) == int function())); // fixed
>> }
>>
>> int main()
>> {
>> foo!main;
>> return 0;
>> }
Oh, I am sorry. I did not realize that D does not allow overloading the address-of
operator. (C++ does, but D is quite restrictive, I have to get used to that)
Therefore, this solution works of course unambiguously.
Well, you could kill alias R func(T); in that case, but still, it makes the
compiler more complicated. :)
Maybe you even want to kill typeof(some_function) then? I think that, without
being able to refer to function types per alias, this could often be a bug.
Timon
More information about the Digitalmars-d-learn
mailing list