diff --git a/unique_ptr.cpp b/unique_ptr.cpp new file mode 100644 index 0000000..4fcb86e --- /dev/null +++ b/unique_ptr.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include + +int main(void) { + std::vector> v; + std::unique_ptr q(new int(42)); + + assert(q != NULL); + // v.push_back(q); + v.push_back(std::move(q)); + assert(q == NULL); + + for(auto &e: v) { + std::cout << *e << std::endl; + } +}