C++20 Dynamic Allocations at Compile-time -- Andreas Fertig
People often say constexpr all the things. Andreas Fertig shows where we can use dynamic memory at compile time.
C++20 Dynamic Allocations at Compile-time
By Andreas Fertig
From the article:
You may already have heard and seen that C++20 brings the ability to allocate dynamic memory at compile-time. This leads to
std::vectorandstd::stringbeing fullyconstexprin C++20. In this article, I like to give you a solid idea of where you can use that.How does dynamic allocation at compile-time work?
First, let’s ensure that we all understand how dynamic allocations at compile-time work. In the early draft of the paper ‘Standard containers and constexpr’ [P0784R1], proposed so-called non-transient allocations. They would have allowed us to allocate memory at compile-time and keep it to run-time. The previously allocated memory would then be promoted to static storage. However, various concerns did lead to allowing only transient allocations. That means what happens at compile-time stays at compile-time. Or in other words, the dynamic memory we allocate at compile-time must be deallocated at compile-time. This restriction makes a lot of the appealing use-cases impossible. I personally think that there are many examples out there that are of only little to no benefit.

Now that we understand the design behind the common STL dequeue implementations, we can peek into the implementation details.

From dynamic container operations to compile-time constants, C++ offers a variety of techniques. In this article, we’ll delve into advanced initialization methods like
The C++ standard library type 
