Pointers and manual memory

This part of the C++ course goes under the containers, to the pointer and the memory it addresses. Address-of and dereference come first, then arithmetic over an array and its one-past-the-end rule, then new and delete and the leak they leave. A vector-like class is rebuilt with a move constructor, and the two smart pointers, a custom deleter and a placement new show what the standard library does with the same bytes. The part ends on alignment, the lifetime of an object and an allocator.

087 Pointers address-of, dereference, nullptr, a pointer as a parameter and the difference from a reference Open 088 Pointer arithmetic walk an array, one past the end, the distance between pointers and the bug that reads past it Open 089 new and delete heap allocation, delete and delete[], a leak, a double delete and why the standard library owns memory Open 090 A vector-like class allocate, grow, copy, release, and the same class rebuilt with a move constructor Open 091 std::unique_ptr exclusive ownership, make_unique, move-only semantics and a factory that returns one Open 092 std::shared_ptr and std::weak_ptr a reference count, make_shared, a cycle that leaks and weak_ptr that breaks it Open 093 Custom deleters close a FILE, wrap a C handle, a deleter as a function object and unique_ptr with a lambda Open 094 Stack, heap, alignment and sizeof where objects live, padding, alignof, and the address of two locals Open 095 Object lifetime raw storage, placement new, an explicit destructor call and std::launder in one sentence Open 096 Allocators and std::pmr operator new, a monotonic_buffer_resource and a vector that allocates from it Open

Lessons