Typeinfo

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 2 21:58:50 PDT 2015


On 3/04/2015 5:34 p.m., Andrei Alexandrescu wrote:
> On 4/2/15 5:52 PM, Rikki Cattermole wrote:
>> Small question, how exactly are you getting the TypeInfo without knowing
>> its exact type at CT?
>
> I just use it at construction, when the type is known. -- Andrei

Ugh:

void main() {
         alias TYPE = immutable(ubyte[]);

         auto TYPEV2 = cast(immutable)TYPE.init;
         alias TYPE2 = typeof(TYPEV2);

         pragma(msg, TYPE);
         pragma(msg, TYPE2);

         static if (is(TYPE2 == TYPE)) {
                 pragma(msg, "immutable");
         } else {
                 pragma(msg, "mutable");
         }
}

cast() should be clearing away the immutable, but for some reason it is 
not working the way I would expect.


More information about the Digitalmars-d mailing list