how to determine if type is final/abstract

JS js.mdnq at gmail.com
Thu Jul 11 16:04:19 PDT 2013


On Thursday, 11 July 2013 at 22:45:47 UTC, JS wrote:
> I have some code that needs to determine if a type 
> isFinalFunction or isAbstractFunction but they don't seem to 
> work:
>
>     foreach(k, t; TargetMembers)
>     {
>         alias TypeTuple!(t.type)[0] type;
>         if (isFinalFunction!(t)) { ... }
>     }
>
> the if statement never gets executed. I've tried using type 
> instead of t and various other things. I suppose the
>
> the function is defined as
>
> final string foo() { ...}
>
> but TargetMembers is
>
> "tuple(FuncInfo!("foo", pure nothrow @safe string()), 
> FuncInfo!("Value", @property int()), FuncInfo!("Value", 
> @property int(int value)))"
>
> I believe the issue is that isFinalFunction requires an actual 
> function symbol but I'm passing it a string?
>
>
> How can I get this to work?

much of the code used can be found at 
http://dpaste.dzfl.pl/209e260b.

I can get the attributes of the function no problem and implement 
the interface except for final functions, which try to get 
implemented again... hence I need to prevent reimplementation of 
final functions but seem to have no way to determine if a 
function is final.


More information about the Digitalmars-d-learn mailing list