Thread overview
how to make interface with return auto
Apr 03, 2017
Eko Wahyudin
Apr 03, 2017
Andrea Fontana
Apr 03, 2017
Kagamin
April 03, 2017
I know it's imposible.

is there's a way if i want to create an interface that have method with return type value is equals with return type of std.palallelism.task

eg.
interface IWorker{
   auto activate(); //on implementation class activate return std.parallelism.task
}

What is the replacement of auto on that interface?

Thank you!
April 03, 2017
On Monday, 3 April 2017 at 12:42:02 UTC, Eko Wahyudin wrote:
> I know it's imposible.
>
> is there's a way if i want to create an interface that have method with return type value is equals with return type of std.palallelism.task
>
> eg.
> interface IWorker{
>    auto activate(); //on implementation class activate return std.parallelism.task
> }
>
> What is the replacement of auto on that interface?
>
> Thank you!

You want to use ReturnType from std.traits.

task() is a template function so you have to define its template params or do a template interface, i guess.

#1:

void f() {
}

interface IWorker{
   ReturnType!(task!f) activate(); //on implementation class activate return std.parallelism.task
}

#2:

interface IWorker(T, Args...){
   ReturnType!(task!(T, Args)) activate(); //on implementation class activate return std.parallelism.task
}


Andrea
April 03, 2017
Or if you want to completely abstract it: https://forum.dlang.org/post/iqxkelatusfocfotphwq@forum.dlang.org