typeof(func!0) != typeof(func!0())
Andrey Zherikov
andrey.zherikov at gmail.com
Mon Aug 22 14:42:10 UTC 2022
On Monday, 22 August 2022 at 12:04:09 UTC, Paul Backus wrote:
> On Monday, 22 August 2022 at 11:24:59 UTC, Andrey Zherikov
> wrote:
>> On Monday, 22 August 2022 at 06:01:11 UTC, JG wrote:
>>> Why not just change to:
>>> alias type = typeof(U().func!0());
>>
>> This is user's code and `U().func!0` is legit syntax.
>
> Workaround: wrap it in a lambda.
>
>
> ```d
> import std.traits;
>
> alias type = ReturnType!(() => U().func!0);
> ```
My situation is that user can write some UDA expression and I'm
checking whether it's of a type `U` using `hasUDA!(sym, U)` and
`getUDAs!(sym, U)`. Is the users uses `U()` or `U().func!0()`,
everything works. But `U().func!0` does not because its type is
not `U`. So to handle this use case it seems I need to implement
my own `hasUDA` and `getUDAs` based on
`ReturnType`.
More information about the Digitalmars-d-learn
mailing list