enum Bar = "Bar";
@("Foo") @Bar int x;
pragma(msg, __traits(getAttributes, x));

This prints: tuple("Foo", "Bar")

How do you run code only if "Bar" is associated with a symbol like x?
I was hoping something like this:
pragma(msg, hasAnnotation!(x, Bar));

Where getAnnotation from (http://forum.dlang.org/thread/[email protected])
was written as:

template hasAnnotation(alias f, Attr) {
  bool helper() {
    foreach(attr; __traits(getAttributes, f))
      static if(is(attr == Attr) || is(typeof(attr) == Attr))
        return true;
    return false;

  }
  enum bool hasAnnotation = helper;
}


I am missing how this can be used.

Thanks
Dan

Reply via email to