I wrote simple code to help me understand smart pointers:
string s = \"str\"; vector > pv ; pv.push_back(unique_ptr
In the std::unique_ptr's destructor it will call delete on the &s pointer which was not allocated via new.
std::unique_ptr
delete
&s
new
Just use:
std::vector vector; vector.emplace_back("str"); std::cout << pv[0] << std::endl;
There's no need for std::unique_ptr there.