Summary
This episode explores std::optional, a C++17 feature that provides a way to represent optional values without dynamic memory allocation. Jason demonstrates key aspects of std::optional, including its memory layout (sized to hold the value plus metadata), value access methods (value() and value_or()), and assignment behavior. He highlights how std::optional handles object lifetimes for contained values and shows how to use emplace() to construct objects in-place when working with move/copy-restricted types, while noting that std::optional isn't constexpr-compatible in C++17.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[allocator.tag]47% match -
[optional]40% match