Thread overview | |||||
---|---|---|---|---|---|
|
April 03, 2017 how to make interface with return auto | ||||
---|---|---|---|---|
| ||||
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 Re: how to make interface with return auto | ||||
---|---|---|---|---|
| ||||
Posted in reply to Eko Wahyudin | 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 Re: how to make interface with return auto | ||||
---|---|---|---|---|
| ||||
Posted in reply to Eko Wahyudin | Or if you want to completely abstract it: https://forum.dlang.org/post/iqxkelatusfocfotphwq@forum.dlang.org |
Copyright © 1999-2021 by the D Language Foundation