From Jason Turner
Watch on YouTube

Summary

This episode introduces C++20's new capability to perform dynamic memory allocation in compile-time constexpr contexts. Jason demonstrates how you can use operator new and delete within constexpr functions with specific constraints: all allocated memory must be freed before returning, memory can't be accessed after deallocation, and pointers to heap memory cannot escape the constexpr context. While initially limited, this paves the way for using containers like std::vector and std::string in constexpr functions.

Resources

Tags