Andrei Alexandrescu wrote:
On 4/6/12 1:47 AM, Walter Bright wrote:__traits(hasAttribute, x, foo)would return true, and: __traits(getAttribute, x, foo) would return the expression (bar+1). The expression would be compile-time only, evaluated at the point of declaration.You also need means to enumerate attributes.
Minimalistically getAttribute*s* should be enough: __traits(getAttributes, x) would return all attributes of x. The rest can be implemented as library templates in std.traits.