template in struct

Namespace rswhite4 at googlemail.com
Sat Mar 23 10:13:00 PDT 2013


On Saturday, 23 March 2013 at 17:08:27 UTC, dsmith wrote:
> How to make workable something like this:
>
> struct S (T...) {
>   T args;
>   string arg_str;
>
>   foreach(i; args) {
>     arg_str ~ to!string(i);
>   }
> }
>
> void some_function(S s) {   // here ... Error: struct S(T...) 
> is used as a type
>   s.args = [a, b, c];
>   string args = s.arg_str;
> }

You must specify the template type of S.


More information about the Digitalmars-d-learn mailing list