Accessing all data in TypeTupple (AliasSeq) and stringify them

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 25 15:42:39 PST 2016


On 02/25/2016 12:53 PM, Voitech wrote:

> template TupleToString(TList...){
>
>      string a;
>      foreach(T;TList){ // Error: declaration expected, not 'foreach'
>          a~=T.stringof;
>      }
>      enum string TupleToString=a;
> }
>
> Of course i can use template function, but wanted to know if can omit this.
> Cheers Voitech
>

You have to wrap the logic in a function and call that function:

template TupleToString(TList...){

     string make_a() {
         string a;
         foreach(T;TList){
             a~=T.stringof;
         }
         return a;
     }

     enum string TupleToString=make_a();
}

Ali



More information about the Digitalmars-d-learn mailing list