How'd I store possible types for each item of a list of Variants ?

oleobal olivier.contrib at
Fri Sep 20 11:28:01 UTC 2019

Thanks for the help!

On Friday, 20 September 2019 at 10:13:49 UTC, Ali Çehreli wrote:
> I don't understand everything here

My bad, I guess once one spends too much time on a problem, it 
gets hard to explain. What if I put it this way ?

   TypedParameter!(ulong, int, string) p1 = new 
TypedParameter!(ulong, int, string)();
   Parameter p2 = new TypedParameter!(ulong, int, string)();

   writeln(typeid(p1.value.AllowedTypes)); // 
   writeln(typeid(p2.value.AllowedTypes)); // ()

My dream would be a way to make that last statement return the 
same thing as the penultimate one.. If that even is possible.

> the 'typeid' expression and the 'TypeInfo' class hierarchy that 
> it returns can be useful in this case.

I can get the correct TypeInfo through virtual functions by 
adding a method like this to Parameter and its sub-classes:

   override TypeInfo_Tuple allowedTypes()
     return typeid(this.value.AllowedTypes);

But as far as I know, I can't use this for instantiating 
templates, can I ? Especially since `this` doesn't exist at 
compile time.

More information about the Digitalmars-d-learn mailing list