I know that vectors are guaranteed to be continuous memory, as well as arrays. So what happens when I do something like this:
std::vector<uint8_t> my_array[10]; my_array[2].push_back(11); my_array[2].push_back(7);
What will the memory look like? If both should be contiguous, will each element of the array after being my_array[2]pushed forward by byte every time I do push_back()on my_array[2]?
my_array[2]
push_back()
Will the situation be the same as when I have an array of structures where the structures have a variable size member, like a string or another vector?
The memory std::vectorcapacity consists of two parts:
std::vector
; , .
, C struct, , std::vector , , . , , . , , .
struct
, push_back, std::vector . , , .
push_back
; std::vector , ( , ).
, std::vector:: push_back , () , . Push_back , , , , , .
, , , .
std::string , , , (, ) char*, .
char*