is expression for template structs/classes instances?

bearophile bearophileHUGS at lycos.com
Tue Dec 21 00:13:25 PST 2010


d coder:

> I want to find if a given struct type is instantiated from a
> particular template struct type. For example:
> 
> struct S (T)  {
>   alias T Type;
>   T t;
> }
> 
> And later I want to find out if a given type is of type S(*)
> (basically any type instantiated from template struct S). In fact I do
> not know the type value T used at the time of instantiating S!(T).

I remember someone has shown here the URL of a module that given an instantiated template, it returns the typetuple of its instantiation arguments. This code maybe returns the alias of the template before instantiation too. But I don't remember the name of the module.
The need expressed in this post is very common, so some standard way to do it is necessary in Phobos or in __traits/meta.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list