On Tuesday, 16 February 2016 at 19:00:19 UTC, Ali Çehreli wrote:

std.traits.TemplateArgsOf:

  http://dlang.org/phobos/std_traits.html#TemplateArgsOf

import std.traits;

class Foo(type1,type2)
{}

class Bar(FooType)
{
    // pragma(msg, TemplateArgsOf!FooType);

    alias ReturnType = TemplateArgsOf!FooType[0];

    ReturnType DoSomething() {
        return ReturnType.init;
    }
}

void main() {
    auto b = new Bar!(Foo!(string, double));
}

However, there are other ways of achieving the same thing at least when returning from a function, e.g.:

    auto DoSomething() {}

(Check out typeof(return) which may be useful in that case.)

Ali

Thanks Ali!

Reply via email to