@trusting generic functions

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 28 17:35:14 PDT 2016


On Saturday, 28 May 2016 at 14:54:13 UTC, Era Scarecrow wrote:
>  Well here's what i got. Maybe someone else will tell me how i 
> did this wrong...

  Using the pragma to output how the lines were being generated i 
finally figured out why it kept complaining about the stack 
pointer and 'this'. So adding in a simple check to ignore 'this' 
entries.

So, final version:

bool areAllFunctionsSafe(T)() {
   foreach(member; __traits(allMembers, T)) {
     static if(member!="this" && isCallable!(__traits(getMember, 
T, member)))
       if (!isSafe!(__traits(getMember, T, member))) return false;
   }
   return true;
}



More information about the Digitalmars-d-learn mailing list