How to move from Unique(someClass) to Unique(someInterface)?

2020-05-16 Thread Konstantin via Digitalmars-d-learn
import std.stdio; import automem; import std.experimental.allocator.mallocator : Mallocator; interface IGetInt { @nogc int GetInt(); } class Foo : IGetInt { @nogc int GetInt() { return 42; } } @nogc void main() { auto foo = Unique!(Foo, Mallocator).construct; pr

Re: How to move from Unique(someClass) to Unique(someInterface)?

2022-11-27 Thread vushu via Digitalmars-d-learn
On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote: import std.stdio; import automem; import std.experimental.allocator.mallocator : Mallocator; interface IGetInt { @nogc int GetInt(); } class Foo : IGetInt { @nogc int GetInt() { return 42; } } @nogc void main()

Re: How to move from Unique(someClass) to Unique(someInterface)?

2022-11-27 Thread Tejas via Digitalmars-d-learn
On Sunday, 27 November 2022 at 17:06:31 UTC, vushu wrote: On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote: [...] I'm actually also very curious about this issue, since I come from c++ where this is possible, and it is a very common functionality for example for dependency inversio

Re: How to move from Unique(someClass) to Unique(someInterface)?

2022-11-28 Thread Gregor Mückl via Digitalmars-d-learn
On Monday, 28 November 2022 at 02:40:28 UTC, Tejas wrote: On Sunday, 27 November 2022 at 17:06:31 UTC, vushu wrote: On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote: [...] I'm actually also very curious about this issue, since I come from c++ where this is possible, and it is a ver