This is extracted from a more complicated example, but I'm wishing to keep a std::vector with unique_pointers to objects. I realize I need to move them in, but I can't seem to figure out how. Also, why can't I delete in the first example?
EDIT: I'm using strings just as an example. The pointed-to object will be a much larger struct.
// Works, but not what I want
std::string* rawJohnP = new(std::string) {"john"};
std::vector<std::string*> rawStringPtrVec {rawJohnP};
delete rawJohnP; // Fails to compile - why?
// how do I make a vector with jUnqPtr?
std::unique_ptr<std::string> jUnqPtr = std::make_unique<std::string>("john");
std::vector<std::unique_ptr<std::string>> stringPtrVec {std::move(jUnqPtr)}; // fails
stringPtrVec.emplace_back(std::move(jUnqPtr)); //fails