Compiles Then Crashes
void take(std::unique_ptr<Widget> p);
std::unique_ptr<Widget> w = std::make_unique<Widget>();
take(w); // A
take(std::move(w)); // B
auto w2 = w; // C
std::unique_ptr<Widget> w3(w.get()); // D
Exactly one of these lines compiles and then destroys the same Widget twice. Which one?
Sign in to answer questions and track your progress
Sign In