On Tuesday, 6 November 2012 at 15:20:43 UTC, Joseph Rushton Wakeling wrote:

Of course the f.T1 notation is my fiction, but it gives the idea of what is needed -- is there a means to extract and use template parameters in this way? I assume something from std.traits but it's not entirely clear what or how ...

Would something like this be what you are after?

import std.stdio;

struct Foo(_T1, _T2, _T3)
{
  alias _T1 T1;
  alias _T2 T2;
  alias _T2 T3;
}

struct Bar(_T1, _T2, _T3)
{
  alias _T1 T1;
  alias _T2 T2;
  alias _T2 T3;
}

auto fooToBar(F)(F f) {
  Bar!(F.T1, F.T2, F.T3) b;
  writeln("I have a ", typeid(typeof(b)));
  return b;
}
void main() {
  alias Foo!(int, string, char) X;
  X x;
  fooToBar(x);
}

Thanks
Dan

Reply via email to