From Jason Turner
Watch on YouTube

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.

Resources

Tags