On Friday, 22 January 2016 at 14:19:30 UTC, rsw0x wrote:
On Friday, 22 January 2016 at 13:28:00 UTC, maik klein wrote:
On Friday, 22 January 2016 at 13:21:11 UTC, rsw0x wrote:
On Friday, 22 January 2016 at 12:57:54 UTC, maik klein wrote:
...

You're looking for AliasSeq in std.meta, it's a tup—er, finite ordered list of types :)

I am already aware of AliasSeq as I have written above. But I could have misused it, would you mind showing an example with TupleRef?

Sorry, I must have skipped that.

Is there a reason you're explicitly using tuples?
Unless I'm misunderstanding you, you're looking for something like...

struct Baz(V...) {
  V vals;
}

which can be used like...

void foo(int, int, int) {

}

void main(){
  auto i = Baz!(int, int, int)();
  foo(i.vals);
}

or am I way off base?

If so, is this similar to what you're looking for?
http://dpaste.dzfl.pl/cbae4c4ed7af

Sorry if I'm nowhere near what you meant.

I think that should work but it only works because you do an implicit conversion with get which is quite nice.

But I was also looking for a more general solution.

I think the mixin solution could be quite nice.

static template unpack(alias f){
  pragma(inline)
  auto into(alias target, Args...)(ref Args args){
    import std.conv;
enum s = `target(`~iota(Args.length).map!(i=>text(`f(args[`,i,`])`)).join(",")~`)`;
    return mixin(s);
  }
}

and use it like:

auto r = unpack!(i => i * 2).into!((a, b) => a + b)(1,2);


The only semi weird thing is that I can use this directly with my version of TupleRef like this:

void foo(ref int, ref int){
}

unpack!((r)=> r.get()).into!(foo)(tref.refTs.expand);


I think that is because "lambda/delegates" can not express ref return types?

So I think I need to do this:

ref auto get(R)(R r){
  return r.get();
}

unpack!(get).into!(foo)(tref.refTs.expand);

Reply via email to