Placement of STL containers

I could not find the exact answer to this question and, therefore, publish here. When I think of a vector, it needs to build objects in contiguous memory. This means that the vector saves the allocated memory and must perform construction in place (= placing a new one) of the objects nested in it. Is this an assumption? In addition, does this mean that the container manually calls the destructor and not causes the deletion? Are there any other assumptions that I am missing here? Does this mean that I can assume that even a custom written new for an object might not be called if I decided to write?

It also makes sense to use the list for a new one and delete it, since we do not need a guarantee of continuous memory. So, is this behavior what leads to the way distributors behave? Please help. Thanks

+5
source share
2 answers

This means that the vector holds the allocated memory and must fulfill the internal construction (= placing a new one) of the objects nested in it. Is this a valid assumption?

Yes

In addition, does this mean that the container manually calls the destructor and not causes the deletion?

Yes

- , ? , , , ?

. , , , . , , ( ) . , , node, .

, .

, new/delete .

, - , , ?

. Allocators - , , , (allocate, deallocate...), ( == , , ).

, ( , -, , malloc -- , ).

, new - , , , . . : , .

new, . - , (), 18.4.1.3, . , (void*), (), , .

+4

, . vector ( ) std::allocator, . .

, " ", , , STL , . , , STL -, .

+3

All Articles