static map as a type function

Stefan Koch uplink.coder at googlemail.com
Thu Sep 24 05:47:45 UTC 2020


wait ....

On Thursday, 24 September 2020 at 05:13:49 UTC, Andrei 
Alexandrescu wrote:
>
> size_t sizeOf(TypeInfo t)
> {
>     return mixin("(" ~ t.toString ~ ").sizeof");
> }
>
What the ....

The sizeof function you wrote is POLYMORPHIC!

it changes shape.
This would work in a DYNAMIC langauge.
but it DOES NOT work in a STATIC langauge.

For your approach to work sizeof needs to be a part of the 
typeinfo object.


More information about the Digitalmars-d mailing list