On Thu, Feb 23, 2012 at 08:15:52AM +0100, Martin Nowak wrote: > Is it possible to forward rvalues through variadic templates? > Having to "move" the value for every layer is suboptimal. > What am I doing wrong? > > ---------- > > import std.algorithm : move; > > void foo(Unique!Handle uniq) > { > auto val = uniq.extract; > assert(val._fd == 1); > val.close(); > } > > void foo(Unique!Handle uniq, string) > { > auto val = uniq.extract; > assert(val._fd == 1); > val.close(); > } > > version (none) > { > void bar(Args...)(Args args) > { > foo(move(args)); // cannot forward variadic arguments ??? > } [...]
I'm not sure, but doesn't this only work if foo() is also variadic? Otherwise I'm not sure how the compiler is supposed to determine, at compile-time, which overload of foo to call from here. And what if args contains 3 arguments, or arguments that don't match any overload of foo? I suppose this *could* be handled by generating runtime code to decide which foo to call, but from what I understand, D doesn't support this currently. T -- Only boring people get bored. -- JM