Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

We're going too deep into this, for alexgartrell's relatively simple claim that covariant return types have a reason for being in the language, and that smart pointers omit that capability.

But just to clarify: no base class implementation is aware of derived classes in the copying case, so your smell doesn't exist. See Scott Meyers' "virtual copy constructor" snippet half way down the page: http://books.google.com/books?id=azvE8V0c-mYC&lpg=PT159&...

You can't do it that neatly without covariant return types. Ergo, you can't do that while returning safe, smart pointers.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: