@safe matching on subclass type

Nordlöw per.nordlow at gmail.com
Wed Jan 17 13:19:42 UTC 2018


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?


More information about the Digitalmars-d-learn mailing list