1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int main(){
unordered_map<int, test> map;
test t1; //output: Construtor, object address: 0x7fffd7933d0b
map.insert({1, std::move(t1)}); //output: Move construtor, address of this: 0x7fffd7933d14, address of r:0x7fffd7933d0b
// Copy construtor, address of this: 0xcdd03c, address of r:0x7fffd7933d14
// destructor, address of this: 0x7fffd7933d14
cout<<"==============="<<endl;
test t2; //output: Construtor, object address: 0x7fffd7933d0c
map.emplace(2, t2); //output: Copy construtor, address of this: 0xcdd07c, address of r:0x7fffd7933d0c
cout<<"==============="<<endl;
return 0;
//output: destructor, address of this: 0x7fffd7933d0c
// destructor, address of this: 0x7fffd7933d0b
// destructor, address of this: 0xcdd07c
// destructor, address of this: 0xcdd03c
}
|