22.5 — std::unique_ptr
At the beginning of the chapter, we discussed how the use of pointers can lead to bugs and memory leaks in some situations. For example, this can happen when a function early returns, or throws an exception, and the pointer is not properly deleted. #include <iostream> void someFunction() { auto* …