How to get the base type of a typedef

MLT none at anone.com
Fri May 1 06:54:23 PDT 2009


Thank you very much!
I'm using tango, and have a problem combining both on OSX. But I just copied the definition:
template BaseTypedef(T) {
    static if( is( T BaseType1 == typedef ) )
        alias BaseTypedef!(BaseType1) BaseTypedef;
    else
        alias T BaseTypedef;
}

and it works! Great!!
Hmmm... but how?
in "is( T BaseType1 == typedef )" Basetype1 seems to be a variable of type T.
Then calling 'alias BaseTypedef!(BaseType1) BaseTypedef;' does not seem to strip away a layer... isn't it still called on a variable of type T? Or does 'is()' do some magic? 


bearophile Wrote:

> MLT:
> > Is there a way to get the base type of location?
> 
> See the BaseTypedef() template in the "templates" module of my dlibs (they are for Phobos):
> http://www.fantascienza.net/leonardo/so/libs_d.zip
> 
> Bye,
> bearophile



More information about the Digitalmars-d-learn mailing list