Currently this will compile
Note:
-no type is supplied to @MyAttribute
-"instantiated" will not be printed

struct MyAttribute(T) {
    pragma(msg, "instantiated");
}

@MyAttribute class SomeClass { }

void main(string[] args) {
    A a = new A();
}

Is there any real(and plausible) use case where providing a template with no argument as a UDA would be useful?

If not, could the above usage be made to instantiate MyAttribute using the type of whatever it's applied to?

So in the above example, MyAttribute would be(or attempted to be) instantiated with type 'SomeClass'.

Currently, you can achieve this(annoyingly and redundantly) like this:

@MyAttribute!SomeClass class SomeClass { }

So if there is no valid usage for untyped template UDA's, can D be made to act as I am proposing?



Reply via email to