Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++unique_ptrSingle-choice MCQ

Why does this fail to compile, and what is the standard fix?

#include <memory> #include <vector> std::unique_ptr<int> make() { return std::make_unique<int>(42); } int main() { std::vector<std::unique_ptr<int>> v; std::unique_ptr<int> p = make(); v.push_back(p); }