From Jason Turner
Watch on YouTube

Summary

This episode explores covariant return types in C++, which allow a derived class to override a virtual method with a more specific return type. Jason demonstrates how covariance works with pointers and references to polymorphic types, but highlights a key limitation: it doesn't work with value returns or smart pointers. He then explores a potential solution by designing a custom covariant smart pointer wrapper that maintains the inheritance relationship while providing memory management benefits.

Resources

Tags