xxxxxxxxxx
import std.stdio, std.range, std.algorithm, std.traits, std.meta;
struct UNIFORM{ string name; }
struct A{
int i1;
int i2; ()
"fuzz") int i3; (
int i4;
}
template getUDA(alias a, U){
static if(hasUDA!(a, U)) enum getUDA = getUDAs!(a, U)[$-1];
else enum getUDA = U.init;
}
pragma(msg, getUDA!(A.i1, UNIFORM)); //UNIFORM(null)
pragma(msg, getUDA!(A.i2, UNIFORM)); //UNIFORM(null)
pragma(msg, getUDA!(A.i3, UNIFORM)); //UNIFORM("fuzz");
pragma(msg, getUDA!(A.i4, UNIFORM)); //Error: initializer must be an expression, not UNIFORM
struct UNIFORM2{ string name=""; }
struct B{ () int i1; }
pragma(msg, getUDA!(B.i1, UNIFORM2)); //UNIFORM("") instead if UNIFORM(null)