I am reading c++ primer move section and confused about the move implementation.
Let us say we have one vector that has 4 elements that occupy 4 consecutive memory locations. MEM[0~3]. The capacity of the vector is 4.
Assuming MEM[4] is now not available as it is occupied by another thread or program or due to whatever reason. Is this possible?
Now we need to add another element. Because we must maintain consecutive memory, we can only find another piece of consecutive memory that can host 8 vector entries, for example MEM[5~12]. In this way, we do copy the contents from MEM[0~3] to MEM[5~8] and then add the new element at MEM[9], right?
There is no way we could reuse the old MEM[0~3] and increase capacity while maintaining consecutive addresses.
If it is linked list, i can understand the move. But for array like, I am a bit confused. Please help explain a bit. Thanks.