Key Takeaways

Get a recap of all the concepts learned in this chapter.

In this chapter, we explored how to use smart pointers and const. We learned what it means to have a const smart pointer or a smart pointer to a const value.

  • When smart pointers are passed by const reference, it’s usually because many developers don’t understand the implications.

  • Passing smart pointers by reference doesn’t share or give ownership. It might lead to situations where we have a valid pointer, but the underlying object was already destroyed.

  • Smart pointers should be passed around by value in general, but there are some exceptional cases when it’s acceptable or desirable to pass by reference and reap the performance gains.

Get hands-on with 1200+ tech skills courses.