Re: Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 07:12:18 UTC, Basile B. wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A

Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A testA() { return alwaysReturnNull(); } B testB() {

Re: Run-time reflection for class inheritance

2019-12-02 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 14:42:46 UTC, Adam D. Ruppe wrote: You can get the type at runtime by simply casting it... if(auto c = cast(EventSocket) event) { // is an event socket } Thanks. I guess you need to be careful about which order you do those tests so as not to cast to more