UDA status
simendsjo
simendsjo at gmail.com
Sun Mar 17 08:04:59 PDT 2013
On Sunday, 17 March 2013 at 14:46:59 UTC, Jacob Carlborg wrote:
> On 2013-03-11 21:41, simendsjo wrote:
>
>> Some update.. Using a custom Tuple(T...) makes things a bit
>> smoother.
>> Here's my first working test with two templates: hasAttr to
>> see if an
>> attribute exists, and attrOfType to get all attributes
>> matching a type
>> (not sure if I should include values..)
>
> You need to use TypeTuple and not Tuple. This is my library
> functions for UDA's:
>
> https://github.com/jacob-carlborg/orange/blob/master/orange/core/Attribute.d
Thanks. I've gotten quite far already:
struct A { int i; }
@("struct S")
struct S {
@("int i", 0, 1, S, A(-1))
int i;
@("string a", "aoeu", 2, string, A(10))
string a;
@("long f(int i)")
long f(int i) { return i; }
}
alias TypeTuple!( TupleWrapper!(S, "struct S")
, TupleWrapper!(S.i, "int i", 0, 1, S, A(-1))
, TupleWrapper!(S.a, "string a", "aoeu", 2,
string, A(10))
, TupleWrapper!(S.f, "long f(int i)")
) Expected;
alias getMembersAndAttributes!S Actual;
static assert(isEqual!(TupleWrapper!Expected,
TupleWrapper!Actual));
More information about the Digitalmars-d-learn
mailing list