Why does the address of the element ping-pong?
I have something like this:
std::vector<double> foo(...);
int main(){
std::vector<double> x;
x.assign(1,0.0);
x = foo(...);
print &x.at(0); // 0x607210
x = foo(...);
print &x.at(0); // 0x607240
x = foo(...);
print &x.at(0); // 0x607210
}
Why does the address of the element ping-pong? The base address of x
remains the same, and the value x.at(0)
is always correct. There's a subtlety here that I do not understand.