From 9f05ea4f04d29ab1958608af37ddfa4f852a3015 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 13 Apr 2014 08:25:23 +0200 Subject: [PATCH] add a unique_ptr test --- unique_ptr.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 unique_ptr.cpp 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; + } +}