Avoiding __traits(getAttributes, ...) on alias

Vlad Levenfeld via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 10 00:46:23 PDT 2014


I'm not really sure. Here is an example of the problem:

const bool has_attribute (T, string member, alias attribute) ()
{
   static if (1) // ok
     mixin(
       `foreach (type; __traits (getAttributes, T.`~member~`))`
         `static if (is (type == attribute))`
           `return true;`
     );
   else // doesn't compile, member is not accessible error
     foreach (type; __traits (getAttributes, mixin(`T.`~member)))
       static if (is (type == attribute))
         return true;
   return false;
}

Maybe its trying to use it inside of __traits that is causing it?


More information about the Digitalmars-d-learn mailing list