Summary
This episode explores C++20's ability to define multiple conditional destructors using concepts. Using a template-like 'optional' class, Jason demonstrates how to leverage the 'requires' clause to selectively provide different destructors based on whether the contained type is trivially destructible. This approach allows libraries to maintain compiler optimizations for trivially destructible types while properly handling non-trivial types, which is crucial for template containers like std::optional.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[concept.destructible]66% match