www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to make interface with return auto

reply Eko Wahyudin <eko.wahyudin yahoo.co.id> writes:
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!
Apr 03
next sibling parent Andrea Fontana <nospam example.com> writes:
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
Apr 03
prev sibling parent Kagamin <spam here.lot> writes:
Or if you want to completely abstract it: 
https://forum.dlang.org/post/iqxkelatusfocfotphwq forum.dlang.org
Apr 03