Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++shared_ptr and weak_ptrSingle-choice MCQ

What is the use_count `member` reports after `sp.reset()`, and is the `Pair` destroyed at that point?

auto sp = std::make_shared<Pair>(Pair{1, 2}); std::shared_ptr<int> member(sp, &sp->b); // aliasing ctor sp.reset(); // what is member.use_count(), and is Pair alive?