template UDA
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 7 15:00:01 PDT 2015
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?
More information about the Digitalmars-d
mailing list