Reputation: 81
It is said that this is related to threads, I don't know much about OS.Thanks for your Answers.
int main(){
shared_ptr<int> p = make_shared<int>(1024);
//do nothing,end my program
}
use_count() will be 1 if I check in main,how to be 0?Or wo need to release operation.
Upvotes: 0
Views: 54
Reputation: 808
Nothing to do with the OS, the shared_ptr
destructor frees the memory and since p
is a local variable the scope will end (i.e call destructor) when main ends.
Upvotes: 3