match class specialization

BCS BCS at pathlink.com
Wed Apr 25 11:39:41 PDT 2007


Frits van Bommel wrote:
> BCS wrote:
> 
>> template TestA(U : A!(T))
>> {
>>     const bool TestA = true;
>> }
>>
>> template TestA(U)
>> {
>>     static if(is(U.superof))
>>         const bool TestA = TestA!(U.superof);
>>     else
>>         const bool TestA = false;
>> }
>>
>> This compiles but doesn't work.
> 
> 
> There's no mention in the spec (at least, that I or Google can find) of 
> a "superof" property. Google did find two previous threads where it's 
> mentioned mentioning in the newsgroup archives, but the only post 
> claiming it should already work seems to be posted by you...
> 
> By the way, above code probably only compiles because .superof is only 
> mentioned in an is() expression (which therefore evaluates to false) and 
> a syntactically-correct declaration in the false branch of a static if.
> 

Exactly, I only said that it "compiles but doesn't work", ... for the 
exact reason you stated. I only wish it worked.

>> I seem to recall that there is no way to
>> get the base class of a type at compile time (that is what .superof is 
>> supposed to be doing) If that can be replaced with something that 
>> acutely works, the above would work, I think.
> 
> 
> As I posted just before you (you probably missed it while posting), this 
> seems to work:
> ---
> static if (is(U Bases == super) && is(Bases[0] == class))
>     //  Bases[0] is th base class
> }
> ---

where dos that come from?? googel gets nothing





More information about the Digitalmars-d-learn mailing list