Hi all,
anyone know how to iterate getSymbolsByUDA ?

I try this code:

enum Attr;
struct A
{
    @Attr int a;
    int b;
}

//-------------------------------------------
//1. Error: need `this` for `a` of type `int`
foreach(sym; getSymbolsByUDA!(A, Attr)){
        writeln(sym.stringof);  
}


for(sizediff_t i=0; i<getSymbolsByUDA!(A, Attr).length; i++){

        //-----------------------------------------------------
        //2. error: variable `i` cannot be read at compile time
        writeln(getSymbolsByUDA!(A, Attr)[i].stringof);
        
}

//-----------------------------------------------------
//3. this OK, but the index is a constant, i don't like it.
writeln(getSymbolsByUDA!(A, Attr)[0].stringof);


Thankyou before

Reply via email to