digitalmars.D.learn - safe matching on subclass type
- =?UTF-8?B?Tm9yZGzDtnc=?= (13/13) Jan 17 2018 Why isn't polymorphic down-casts such as in the following pattern
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/15) Jan 17 2018 Just discovered that the base instance was const. My mistake...
Why isn't polymorphic down-casts such as in the following pattern matching on sub-class class Base {} class Sub : Base {} safe unittest { auto base = new Base(); if (auto sub = cast(Sub)base) { // use sub } } allowed in safe D?
Jan 17 2018
On Wednesday, 17 January 2018 at 13:19:42 UTC, Nordlöw wrote:Why isn't polymorphic down-casts such as in the following pattern matching on sub-class class Base {} class Sub : Base {} safe unittest { auto base = new Base(); if (auto sub = cast(Sub)base) { // use sub } } allowed in safe D?Just discovered that the base instance was const. My mistake...
Jan 17 2018