- In the code below, my understanding is a and b are not sharing the ownership. Instead, they are two separate smart pointer, each of them has individual control block with ref_count = 1. Is my understanding correct?
std::shared_ptr<Foo> a = make_shared<Foo>();
std::shared_ptr<Foo> b = make_shared<Foo>();
- the correct way to use shared_ptr which share the ownership and increase ref_cnt is call make_shared once to initialize the memory and use copy/assign to increase the ref_cnt and share owernship. For example:
std::shared_ptr<Foo> a = make_shared<Foo>();
auto b = a;
auto b(a);
Are the two points I mentioned above correct?
Thank you in advance!