Hard to word this question right, but is it possible to get the UDAs assigned to a class/structure's member variable declaration, within that variable's definition? e.g.
import std.stdio;
import std.traits;
enum SPECIAL;
struct Foo {
void foo() {
static if (hasUDA!(typeof(this), SPECIAL))
writeln("special");
else
writeln("not special");
}
}
struct Bar {
@SPECIAL Foo foo;
}
void main() {
Foo foo;
foo.foo;
Bar bar;
bar.foo.foo;
}
This doesn't work of course, @SPECIAL
isn't applied to struct Foo
itself so no UDA is found by hasUDA!Foo
. Without iterating Bar directly, is there some way to detect within Foo's member functions, that the Foo being called is declared with @SPECIAL
inside its parent structure?