3 ms·
> C++ doesn't track lifetimes. Of course, C++ does not have lifetimes (in the Rust sense), but your original claim was that C++ does not seperate allocation fr
by spacechild1 4y ago
> C++ doesn't track lifetimes.
Of course, C++ does not have lifetimes (in the Rust sense), but your original claim was that C++ does not seperate allocation from construction.
> Such a separation is only useful in specific situations, such as the one the original article mentions.
It is actually quite common. You don't even have to reach for advanced things like memory/object pools. For example, if you want to implement a dynamically sized array type (std::vector), you typically want to increase the storage independently from the number of objects.
But then again, maybe you are talking about something different here...
---
Also, I may need to clarify some things about C++ allocators. They are not used to allocate storage for the object itself, but rather control how an object allocates memory for its subobjects. Keep in mind that the object itself may exist in a different kind of storage than its subobjects. For example, the object may live on the stack, but its subobjects must be allocated dynamically.
- spacechild1 4y agoEDIT > but your original claim was that C++ does not seperate allocation from construction. At least that's how I interpreted it.