struct blu { blu(int i) : m_i(i) { std::cout << "--new " << value() << std::endl; } ~blu() { std::cout << "--deleting " << value() << std::endl; } std::string value() const { std::stringstream stream; stream << m_i << " (0x" << std::hex << &m_i << ")"; return stream.str(); } int m_i; }; int main(int argc, char* argv[]) { std::cout << "|\n|\n"; std::vector<std::unique_ptr<blu> > bla; bla.push_back(std::make_unique<blu>(0)); bla.push_back(std::make_unique<blu>(1)); bla.push_back(std::make_unique<blu>(2)); bla.push_back(std::make_unique<blu>(3)); bla.push_back(std::make_unique<blu>(4)); std::cout << "bla.size(): " << bla.size() << std::endl; auto ble = std::move(bla); std::cout << "bla.size(): " << bla.size() << std::endl; std::cout << "ble.size(): " << ble.size() << std::endl; std::cout << "bla:" << std::endl; for(auto& b : bla) { std::cout << b->value() << std::endl; } std::cout << "ble:" << std::endl; for(auto& b : ble) { std::cout << b->value() << std::endl; } return 0; }