Re: opCast + dtor error

2021-12-29 Thread vit via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 01:00:53 UTC, Tejas wrote: On Tuesday, 28 December 2021 at 18:27:36 UTC, vit wrote: [...] Since a destructor ignores `const`, I think adding the `~this` to Foo manually is somehow making the compiler have to actually cast away const, which it is doing via

Re: opCast + dtor error

2021-12-28 Thread Tejas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 18:27:36 UTC, vit wrote: Hi, why this code doesn't compile? ```d struct Foo{ bool opCast(T : bool)()const{ assert(0); } ~this(){} } struct Bar{ const Foo foo; } void main(){ } ``` Error: template instance `opCast!(Foo)` does not

opCast + dtor error

2021-12-28 Thread vit via Digitalmars-d-learn
Hi, why this code doesn't compile? ```d struct Foo{ bool opCast(T : bool)()const{ assert(0); } ~this(){} } struct Bar{ const Foo foo; } void main(){ } ``` Error: template instance `opCast!(Foo)` does not match template declaration `opCast(T : bool)()`