digitalmars.D.learn - how to make interface with return auto
- Eko Wahyudin (11/11) Apr 03 2017 I know it's imposible.
- Andrea Fontana (17/28) Apr 03 2017 You want to use ReturnType from std.traits.
- Kagamin (2/2) Apr 03 2017 Or if you want to completely abstract it:
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 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. void f() { } interface IWorker{ ReturnType!(task!f) activate(); //on implementation class activate return std.parallelism.task } interface IWorker(T, Args...){ ReturnType!(task!(T, Args)) activate(); //on implementation class activate return std.parallelism.task } Andrea
Apr 03 2017
Or if you want to completely abstract it: https://forum.dlang.org/post/iqxkelatusfocfotphwq forum.dlang.org
Apr 03 2017