Function accepting variadic arguments

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 20 05:06:31 PST 2016


On Wednesday, 20 January 2016 at 13:04:23 UTC, Daniel Kozak wrote:
> V Wed, 20 Jan 2016 12:38:20 +0000
> pineapple via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com>
> napsáno:
>
>
> import std.stdio;
>
> struct S
> {
>     this(Args...)(Args args)
>     {
>         foreach(Type, Value;args)
>         {
>             writefln("Type: %s value: %s", Args[Type].stringof, 
> Value);
>         }
>     }
> }
>
> void main()
> {
>     auto s = S(1, "string");
> }

Type should be named Index :)




More information about the Digitalmars-d-learn mailing list