Is a std::unique_ptr moved into a std::vector when using push_back?

Viewed 6019

I have a question about how a std::unique_ptr is inserted into a std::vector. Imagine I have a function that produces objects as follows:

std::unique_ptr<CObject> createObjects()
{
    return std::unique_ptr<CObject> (new CObject());
}

Now in my code, I have a std::vector<std::unique_ptr<CObjects>> vec and I insert elements like so:

vec.push_back(createObjects());

Now my question is: Is the unique_ptr moved into the vector or is it copied?

1 Answers
Related