Summary
In Chapter 5, we spent some time on the proper usage of standard smart pointers. In the current chapter, we “dirtied our hands,” so to speak, and we wrote homemade (and simplified) versions of unique_ptr<T> and shared_ptr<T>. As mentioned more than once, this is meant as an educational exploration, as your library vendor assuredly provides significantly better (more complete, more performant, better tested, etc.) implementations in both cases.
In this chapter, we also explored the possibility of providing homemade smart pointer types, with a policy-based dup_ptr<T> based on three distinct approaches to the selection of a duplication algorithm. The intent was to show that it can be done, how it can be done, and how we can provide reasonable, usable defaults without blocking user code with more exotic requirements.
Toward the end of this chapter, we examined some relatively simple (but useful) smart (well, lightly smart) pointers that can...