Thread overview |
---|
May 19, 2020 Alias function declaration. | ||||
---|---|---|---|---|
| ||||
Hello. I just want to find what is exactly the difference between: alias _ = void function(int); alias void _(int); Because it's seem that the latter can't be used in the declaration of an array (eg: _[] ...). I think the first is a pointer to function and the second is a function type itself but I'm not sure. Regard. |
May 20, 2020 Re: Alias function declaration. | ||||
---|---|---|---|---|
| ||||
Posted in reply to MaoKo | On Tuesday, 19 May 2020 at 22:04:49 UTC, MaoKo wrote:
> Hello. I just want to find what is exactly the difference between:
> alias _ = void function(int);
> alias void _(int);
> Because it's seem that the latter can't be used in the declaration of an array (eg: _[] ...).
> I think the first is a pointer to function and the second is a function type itself but I'm not sure.
yes this is correct. To declare a function type using the first form is also possible:
alias TF1 = void(int);
alias void TF2(int);
static assert (is(TF1 == TF2));
|
May 21, 2020 Re: Alias function declaration. | ||||
---|---|---|---|---|
| ||||
Posted in reply to user1234 | On Wednesday, 20 May 2020 at 04:50:42 UTC, user1234 wrote:
> On Tuesday, 19 May 2020 at 22:04:49 UTC, MaoKo wrote:
>> Hello. I just want to find what is exactly the difference between:
>> alias _ = void function(int);
>> alias void _(int);
>> Because it's seem that the latter can't be used in the declaration of an array (eg: _[] ...).
>> I think the first is a pointer to function and the second is a function type itself but I'm not sure.
>
> yes this is correct. To declare a function type using the first form is also possible:
>
> alias TF1 = void(int);
> alias void TF2(int);
> static assert (is(TF1 == TF2));
Ok thanks you :D
|
Copyright © 1999-2021 by the D Language Foundation