Suppose that I have two struct templates which take identical parameter lists:

    struct Foo(T1, T2, T3)
    {
        ...
    }

    struct Bar(T1, T2, T3)
    {
        ...
    }

Now suppose that I have a Foo which has been instantiated with a given set of parameters. Is there any way for me to say, "now instantiate a Bar with the same parameters?"

The use-case I'm thinking of is a function something like this (somewhat pseudo-code-y):

    auto fooToBar(FooInstance f)
    {
        Bar!(f.T1, f.T2, f.T3) b;
        // set values etc.
        return b;
    }

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 ...

Reply via email to